Created
December 31, 2021 05:18
-
-
Save ryaninvents/d52c872d596fc8c6d765abe0e369898d 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
var iso31662 = require("iso-3166-2"); | |
function typeValue(a) { | |
switch (a.type) { | |
case 'Outlying area': return 1; | |
default: return 0; | |
} | |
}; | |
[...Object.entries(iso31662.country('USA').sub)].sort(([,a], [,b]) => { | |
return (typeValue(a) - typeValue(b)) || a.name.localeCompare(b.name) | |
}).map(([key]) => iso31662.subdivision(key)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment