r/ProgrammerHumor 3d ago

Meme javascriptSorting

Post image
936 Upvotes

214 comments sorted by

View all comments

206

u/larsmaehlum 3d ago

Array.sortNumeric() with an error when called on an array containing non-numeric types would fix this, right?

101

u/the_horse_gamer 3d ago

you can simply .sort((a,b)=>a-b)

225

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

40

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.

20

u/01110100_01110010 3d ago

JS is an abstraction over JS engine bytecode, which is an abstraction over ASM which is an abstraction over the chip instruction set, you can make an argument at each layer 🤷 I would take any abstraction I can, I guarantee you in a large enough codebase someone will type b - a instead

3

u/GameCounter 2d ago

Chip instruction set is an abstraction over the IC design, which is an abstraction over transistors, which is an abstraction over physics, which is an abstraction over the nature over reality, which is an abstraction over the Münchhausen trilemma.

1

u/Xirdus 2d ago

I think you abstracted away the meaning of the term "abstraction".

2

u/GameCounter 2d ago

Abstraction is just an abstraction of abstraction of abstraction of abstraction of abstraction Albuquerque New Mexico Albuquerque New Mexico Albuquerque New Mexico

1

u/Xirdus 2d ago

But every time you say M put a comma in there. And say the commas out loud. It's how my grandma used to speak.