Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. function sortstuff(data,ascending, sortKey=0){
  2. let key = sortKey || Object.keys(data[0])[0]
  3. return data.sort(function(a,b) {
  4. if ( a[key] < b[key] )
  5. return ascending ? -1 : 1;
  6. if ( a[key] > b[key] )
  7. return ascending ? 1 : -1;
  8. return 0;
  9. } );
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement