-
-
Save refack/8fc2bbdf084f9ad28f900ad5a4f80a14 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"name": "sort-error", "version": "0.0.0", "bin": "./sort.js"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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