On 6 Jun 2014, at 01:15, Axel Rauschmayer <a...@rauschma.de> wrote:

> It’d be nice to have a built-in way for comparing numbers, e.g. when sorting 
> arrays.
> 
> ```js
> // Compact ECMAScript 6 solution
> // Risk: number overflow
> [1, 5, 3, 12, 2].sort((a,b) => a-b)
> 
> // Proposed new function:
> [1, 5, 3, 12, 2].sort(Number.compare)
> ```

That sorts in ascending order. What if you need to sort in descending order? 
Would there need to be a built-in function for that too?
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to