keysort

Sorts an Array of Objects with SQL ORDER BY clause

keysort

Sorts an Array of Objects based on key values, like an SQL ORDER BY

Example

var arr = [{abc: 123124, xyz: 5}, {abc: 123124, xyz: 6}, {abc: 2, xyz: 5}];
 
keysort(arr, "abc"); // [{abc: 2, xyz: 5}, {abc: 123124, xyz: 5}, {abc: 123124, xyz: 6}]; 
keysort(arr, "abc, xyz desc"); // [{abc: 2, xyz: 5}, {abc: 123124, xyz: 6}, {abc: 123124, xyz: 5}]; 
  • AMD loaders (require.js, cujo.js, etc.)
  • node.js (npm install keysort)
  • script tag

Copyright (c) 2013 Jason Mulligan
Licensed under the BSD-3 license.