Skip to content

Instantly share code, notes, and snippets.

@refack
Forked from hudochenkov/package.json
Last active November 10, 2018 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save refack/8fc2bbdf084f9ad28f900ad5a4f80a14 to your computer and use it in GitHub Desktop.
Save refack/8fc2bbdf084f9ad28f900ad5a4f80a14 to your computer and use it in GitHub Desktop.
{"name": "sort-error", "version": "0.0.0", "bin": "./sort.js"}
#!/usr/bin/env node
const declarations = [
{p: 'mottob', id: 1},
{p: 'bottom', id: 2},
{p: 'mottob', id: 3},
{p: 'bottom', id: 4},
];
declarations.sort((a, b) => {
const ret = sortDeclarations(a, b);
console.log(`a: %o, b: %o - %d`, a, b, ret);
return ret
});
console.log(declarations);
function sortDeclarations(a, b) {
if (a.p === 'bottom') {
return -1;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment