[Community Puzzle] Dynamic sorting

I pass everything but for some reason fail validators 02/04. Any hint on what might be tricky for these?

Seems like the problem is underspecified. It doesn’t say what to do in the case where multiple items are the same for all categories in the sorting expression.

2 Likes

The given criteria are enough to sort all entries with different orders, will not result in “all-the-same” situation.

I must be misunderstanding something, then. For example, test case 04 has these two items with the same age, name, and size. BTW, I tried also sorting by ID as a last step, that doesn’t help with the validator tests.

+age-name+size int,string,int
id:18,name:eva,age:18,size:185
id:56,name:eva,age:18,size:185

2 Likes

hmm…not sure have the statement or test cases been changed from what I remember.

The output statement “the sorted objects ids (there will always be an string id property)” could be incorrect - I think the id property is integer, not string.
And yes, when all given properties are the same, the final ordering is by the id in asc order. I agree this should be written into the statement as well.

I’m trying to use Linq for sorting, but can’t figure out how to do it dynamically. Can someone give me a resource or tips? I’d appreciate a nudge in the right direction. Thanks.

did you try searching for linq in the top search bar? There might be some useful resources about linq on CodinGame.
This one maybe?
https://www.codingame.com/playgrounds/213/using-c-linq---a-practical-overview

Is it possible to get any hint why validator 02 may be failed? I see that problem statement was updated so it is clear that id is integer and final ordering should take id into account, so unsure where to go next.

That is a great resource and I learned some things, but it doesn’t cover the dynamic sorting required in this puzzle. I’ll keep working on it. Thanks for the reply.

1 Like