The
toSorted()method ofArrayinstances is the copying version of thesort()method. It returns a new array with the elements sorted in ascending order. (c) MDN
🐊Putout plugin adds ability to apply toSorted.
Checkout in 🐊Putout Editor.
npm i @putout/plugin-apply-to-sorted
{
"rules": {
"apply-to-sorted": "on"
}
}[...a].sort((a, b) => a - b);a.toSorted((a, b) => a - b);MIT