Skip to content

Commit

Permalink
Updated readme to take advantage of the existence of [].toSorted.
Browse files Browse the repository at this point in the history
  • Loading branch information
Pimm committed Jan 2, 2024
1 parent 598075d commit 08ff672
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions readme-nl.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Stel je voor dat we deze array van getallen sorteren, vertegenwoordigd als strin
```
`'12'` zou voor `'3.14'` worden geplaatst als we sorteren zonder vergelijkfunctie, dus zo een functie is vereist:
```javascript
['12', '1', '3.14'].sort((a, b) => parseFloat(a) - parseFloat(b));
['12', '1', '3.14'].toSorted((a, b) => parseFloat(a) - parseFloat(b));
```
Dat werkt!

Expand Down Expand Up @@ -63,7 +63,7 @@ const sortedArray = mapSort(

## Opmerkingen

* In tegenstelling tot [`[].sort`][mdn-sort], **sorteert deze bibliotheek niet _in-place_**. Er wordt een nieuwe, gesorteerde array teruggegeven. De originele array wordt niet beïnvloed.
* Deze bibliotheek sorteert niet _in-place_, en lijkt daarmee meer op [`[].toSorted`][mdn-tosorted] dan [`[].sort`][mdn-sort].
* Deze bibliotheek sorteert [waarschijnlijk][stable-sorting] stabiel.

# Licentie (X11/MIT)
Expand All @@ -76,5 +76,6 @@ The above copyright notice and this permission notice shall be included in all c
**The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. in no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the Software or the use or other dealings in the Software.**


[mdn-tosorted]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted
[mdn-sort]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
[stable-sorting]: https://github.com/Pimm/mapsort/blob/master/documentation/stable-sorting-nl.md
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Imagine we are sorting this array of numbers, represented as strings:
```
Sorting them with no compare function would place `'12'` before `'3.14'`, so we need such a function:
```javascript
['12', '1', '3.14'].sort((a, b) => parseFloat(a) - parseFloat(b));
['12', '1', '3.14'].toSorted((a, b) => parseFloat(a) - parseFloat(b));
```
This works!

Expand Down Expand Up @@ -63,7 +63,7 @@ const sortedArray = mapSort(

## Notes

* Contrary to [`[].sort`][mdn-sort], this library **does not sort in-place**. It returns a new, sorted array. The original array is left untouched
* This library does not sort in-place, making it more similar to [`[].toSorted`][mdn-tosorted] than [`[].sort`][mdn-sort].
* This library [probably][stable-sorting] performs stable sorting.

# License (X11/MIT)
Expand All @@ -76,5 +76,6 @@ The above copyright notice and this permission notice shall be included in all c
**The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. in no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the Software or the use or other dealings in the Software.**


[mdn-tosorted]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/toSorted
[mdn-sort]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
[stable-sorting]: https://github.com/Pimm/mapsort/blob/master/documentation/stable-sorting.md

0 comments on commit 08ff672

Please sign in to comment.