sortByKey
should be a function.
testString: assert(typeof sortByKey == 'function');
- text: 'sortByKey([{key: 3, value: "foo"}, {key: 2, value: "bar"}, {key: 4, value: "baz"}, {key: 1, value: 42}, {key: 5, value: "another string"}])
should return an array.'
testString: assert(Array.isArray(sortByKey([{key:3, value:"foo"}, {key:2, value:"bar"}, {key:4, value:"baz"}, {key:1, value:42}, {key:5, value:"another string"}])));
- text: 'sortByKey([{key: 3, value: "foo"}, {key: 2, value: "bar"}, {key: 4, value: "baz"}, {key: 1, value: 42}, {key: 5, value: "another string"}])
should return [{key: 1, value: 42}, {key: 2, value: "bar"}, {key: 3, value: "foo"}, {key: 4, value: "baz"}, {key: 5, value: "another string"}]
.'
testString: assert.deepEqual(sortByKey([{key:3, value:"foo"}, {key:2, value:"bar"}, {key:4, value:"baz"}, {key:1, value:42}, {key:5, value:"another string"}]), [{key:1, value:42}, {key:2, value:"bar"}, {key:3, value:"foo"}, {key:4, value:"baz"}, {key:5, value:"another string"}]);
- text: 'sortByKey([{key: 3, name: "Joe"}, {key: 4, name: "Bill"}, {key: 20, name: "Alice"}, {key: 5, name: "Harry"}])
should return [{key: 3, name: "Joe"}, {key: 4, name: "Bill"}, {key: 5, name: "Harry"}, {key: 20, name: "Alice"}]
.'
testString: assert.deepEqual(sortByKey([{key:3, name:"Joe"}, {key:4, name:"Bill"}, {key:20, name:"Alice"}, {key:5, name:"Harry"}]), [{key:3, name:"Joe"}, {key:4, name:"Bill"}, {key:5, name:"Harry"}, {key:20, name:"Alice"}]);
- text: 'sortByKey([{key: 2341, name: "Adam"}, {key: 122, name: "Bernie"}, {key: 19, name: "David"}, {key: 5531, name: "Joe"}, {key: 1234, name: "Walter"}])
should return [{key: 19, name: "David"}, {key: 122, name: "Bernie"}, {key: 1234, name: "Walter"}, {key: 2341, name: "Adam"}, {key: 5531, name: "Joe"}]
.'
testString: assert.deepEqual(sortByKey([{key:2341, name:"Adam"}, {key:122, name:"Bernie"}, {key:19, name:"David"}, {key:5531, name:"Joe"}, {key:1234, name:"Walter"}]), [{key:19, name:"David"}, {key:122, name:"Bernie"}, {key:1234, name:"Walter"}, {key:2341, name:"Adam"}, {key:5531, name:"Joe"}]);
```