That's the solution anyone would expect, you don't need to know any algorithm for sort, but passing a comparator is such a basic thing.
You don't even need any algorithm to solve the problem.
Online since 1990 Yes! I started with Gopher. I do modern Web Component Development with technologies supported by **all** WHATWG partners (Apple, Google, Microsoft & Mozilla)
Typical example where humans fail. When they see numbers they want to calculate with numbers. Almost all 30+ answers in the mentioned SO thread do so.
I just added my answer. And probably would have failed every job interview if they only excepted the solution they themselves came up with.
That's the solution anyone would expect, you don't need to know any algorithm for sort, but passing a comparator is such a basic thing.
You don't even need any algorithm to solve the problem.
Typical example where humans fail. When they see numbers they want to calculate with numbers. Almost all 30+ answers in the mentioned SO thread do so.
I just added my answer. And probably would have failed every job interview if they only excepted the solution they themselves came up with.
stackoverflow.com/questions/683259...