I have been coding in Java for over 10 years now. And I often admire the completeness of Java core packaging.
Recently I started working more on Python and found it great for building ETL tasks, standalone script jobs, automation clients etc. I know we can do a lot more than that, but those are my current use cases.
One of the requirement I recently had was, given an array of objects sort them using a custom comparison logic.
The few options I thought about were:
But I quickly realized that the above methods are equivalent to Comparable<T>.compareTo(T> in Java
And the solutions is functools.cmp_to_key function. Here is an example for solving leetcode #179 problem