7

Yesterday I spent almost 3 hours trying to sort an array of objects in java. I'm a person who has written a lot of python and dart code and java is just so daunting. Every simple thing is so complicated.
You can sort a list of objects wrt any parameter using a one liner in python.
Finally after copy pasting a lot of code from stack overflow the thing got sorted. And the worst part I don't even know how the thing works.

Comments
  • 2
    What are u trying to sort? Geeks for Geeks is my go to spot. They're not always optimized/perfect but they point you in the right direction. And you can see most solutions in multiple languages

    https://geeksforgeeks.org/merge-sor...
  • 1
    Off topic, in C# is just as short as in Python, almost
  • 2
    You can do sorting with one-liners in modern (8+, using lambdas/closures) Java too. You probably were looking at a ton of outdated answers because the old approach was definitely ugly and verbose af, and it's quite a tedious process when a language evolves to keep all the SO answers updated.
  • 1
    sorted(a, key=b)
    Arrays.sort(a, ::b)
Add Comment