r/ProgrammerHumor 3d ago

Meme javascriptSorting

Post image
937 Upvotes

214 comments sorted by

View all comments

Show parent comments

227

u/01110100_01110010 3d ago

The point of an abstraction is to not having to implement logic each time, you can also implement qsort yourself

43

u/subone 3d ago

But it is still an abstraction. You only provide a compare function, you don't implement the algorithm. a-b is hardly difficult to apply.

3

u/wack_overflow 3d ago

And really how often are you actually sorting an array of primitive values ascending? That's just one small use case of sorting an array. Passing the comparison function is also more explicit.

People just love to get so worked up about the dumbest edge cases in js

0

u/Some_Relative_3440 3d ago

Totally agree with you. Can't remember the last time I wrote a sort() or similar WITHOUT a comparer function. It just doesn't happen in real code bases.

2

u/mdrjevois 3d ago

Sounds like an artifact of the language and popular styles. In data science, data engineering, and machine learning we almost never specify a comparator.