ChainSorter Demo

Preamble

The following code is included in the subsequent examples, but hidden so as not to pollute them.

const {ChainSorter} = require("chainsorter"); const names = [{ "first": "Carl", "last": "Archer", "id": 0 }, { "first": "Burt", "last": "Birch", "id": 1 }, { "first": "Carl", "last": "Cross", "id": 2 }, { "first": "Albert", "last": "Archer", "id": 3 }];

Ascending, by last name and then first name.

Descending by last name, ascending by first name.

A custom function – show Carls first.

You can also pass in your keys as an array. Plus, if your data is an array of arrays, you use the indices as your keys.