Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It can (and should!) be written more elegantly

[5, 10, 1].sort(function(a, b) { return a - b })

Or, in ES6:

[5, 10, 1].sort((a, b) => { a - b })

That's starting to look pretty nice if you ask me.



Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: