Skip to content

Instantly share code, notes, and snippets.

@brecht
Created May 29, 2019 12:03
Show Gist options
  • Select an option

  • Save brecht/cfc78cc00031da2777bf9f44bce27c80 to your computer and use it in GitHub Desktop.

Select an option

Save brecht/cfc78cc00031da2777bf9f44bce27c80 to your computer and use it in GitHub Desktop.
Sort array of objects by string property
arrayOfObjects.sort(
(a, b) => (a.propName > b.propName) ? 1 : ((b.propName > a.propName) ? -1 : 0)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment