Created
May 18, 2018 17:01
-
-
Save ancms2600/471affc9a414718c90f6b9749d5da3e5 to your computer and use it in GitHub Desktop.
Javascript sortBy multi-dimensional (e.g., `SORT BY state ASC, city ASC`)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sortBy = (...k) => (a,b) => ((k)=> (null==k || a[k]===b[k]) ? 0 : a[k]<=b[k] ? -1 : 1 )(k.find(_k=>a[_k]!==b[_k])); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment