<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script src="https://cdn.rawgit.com/lodash/lodash/3.10.1/lodash.min.js"></script>
</body>
</html>
var list = [
{
"estados": [
{
"idEstado": 0,
"nombre": "Jalisco",
"localidades": [
{
"nombre": "Mazamitla",
"idEstado": 0,
"promedio": 8,
"oferta": {
"gen": 7,
"ecas": 7,
"va": 8,
"ca": 8,
"feh": 8,
"esd": 8,
"cia": 8,
"egct": 7,
"rpc": 8
},
"demanda": {
"gen": 7,
"ata": 8,
"ep": 7,
"gp": 7
},
"seguridad": {
"gen": 4,
"ps": 8,
"rn": 8
},
"comunidad": {
"gen": 8,
"h": 8,
"e": 8,
"rse": 8
},
"mercadotecnia": {
"gen": 7,
"ev1": 8,
"ev2": 8,
"ed": 8,
"pp": 8,
"dit": 8
},
"accesibilidad": {
"gen": 8,
"ef": 8,
"st": 8,
"ci": 8,
"cc": 8
}
},
{
"nombre": "San Sebastian del Oeste",
"idEstado": 0,
"promedio": 6,
"oferta": {
"gen": 5,
"ecas": 6,
"va": 5,
"ca": 6,
"feh": 5,
"esd": 6,
"cia": 6,
"egct": 6,
"rpc": 6
},
"demanda": {
"gen": 6,
"ata": 6,
"ep": 6,
"gp": 6
},
"seguridad": {
"gen": 6,
"ps": 6,
"rn": 6
},
"comunidad": {
"gen": 6,
"h": 6,
"e": 6,
"rse": 6
},
"mercadotecnia": {
"gen": "N/A",
"ev1": 6,
"ev2": 6,
"ed": 6,
"pp": 6,
"dit": 6
},
"accesibilidad": {
"gen": 1,
"ef": 6,
"st": 6,
"ci": 6,
"cc": 8
}
},
{
"nombre": "Tequila",
"idEstado": 0,
"promedio": 8,
"oferta": {
"gen": 7,
"ecas": 2,
"va": 8,
"ca": 7,
"feh": 7,
"esd": 8,
"cia": 8,
"egct": 5,
"rpc": 8
},
"demanda": {
"gen": 5,
"ata": 8,
"ep": 5,
"gp": 5
},
"seguridad": {
"gen": 7,
"ps": 8,
"rn": 7
},
"comunidad": {
"gen": 8,
"h": 7,
"e": 7,
"rse": 8
},
"mercadotecnia": {
"gen": 5,
"ev1": 7,
"ev2": 7,
"ed": 7,
"pp": 8,
"dit": 8
},
"accesibilidad": {
"gen": 7,
"ef": 8,
"st": 8,
"ci": 8,
"cc": 7
}
},
{
"nombre": "Tapalpa",
"idEstado": 0,
"promedio": 5,
"oferta": {
"gen": 8,
"ecas": 6,
"va": 6,
"ca": 8,
"feh": 8,
"esd": 5,
"cia": 5,
"egct": 5,
"rpc": 5
},
"demanda": {
"gen": 8,
"ata": 5,
"ep": 5,
"gp": 6
},
"seguridad": {
"gen": 8,
"ps": 5,
"rn": 8
},
"comunidad": {
"gen": 5,
"h": 8,
"e": 8,
"rse": 6
},
"mercadotecnia": {
"gen": 5,
"ev1": 8,
"ev2": 8,
"ed": 8,
"pp": 5,
"dit": 5
},
"accesibilidad": {
"gen": 8,
"ef": 5,
"st": 5,
"ci": 5,
"cc": 8
}
}
]
},
{
"nombre": "Coahuila",
"idEstado": 1,
"localidades": [
{
"nombre": "Arteaga",
"idEstado": 1,
"promedio": 4,
"oferta": {
"gen": 7,
"ecas": 6,
"va": 6,
"ca": 6,
"feh": 7,
"esd": 2,
"cia": 2,
"egct": 2,
"rpc": 7
},
"demanda": {
"gen": 2,
"ata": 2,
"ep": 2,
"gp": 4
},
"seguridad": {
"gen": 4,
"ps": 6,
"rn": 6
},
"comunidad": {
"gen": 4,
"h": 4,
"e": 2,
"rse": 2
},
"mercadotecnia": {
"gen": 2,
"ev2": 2,
"ed": 4,
"pp": 6,
"dit": 2
},
"accesibilidad": {
"gen": 6,
"ef": 4,
"st": 2,
"ci": 2,
"cc": 4
}
}
]
},
{
"nombre": "Puebla",
"idEstado": 2,
"promedio": 8,
"localidades": [
{
"nombre": "Zacatlan",
"idEstado": 2,
"promedio": 5,
"oferta": {
"gen": 7,
"ecas": 8,
"va": 8,
"ca": 7,
"feh": 7,
"esd": 8,
"cia": 8,
"egct": 5,
"rpc": 8
},
"demanda": {
"gen": 7,
"ata": 8,
"ep": 5,
"gp": 5
},
"seguridad": {
"gen": 7,
"ps": 8,
"rn": 7
},
"comunidad": {
"gen": 8,
"h": 7,
"e": 7,
"rse": 8
},
"mercadotecnia": {
"gen": 8,
"ev1": 7,
"ev2": 7,
"ed": 7,
"pp": 8,
"dit": 8
},
"accesibilidad": {
"gen": 7,
"ef": 8,
"st": 8,
"ci": 8,
"cc": 7
}
}
]
},
{
"nombre": "Sonora",
"idEstado": 3,
"promedio": 6,
"localidades": [
{
"nombre": "Hermosillo",
"idEstado": 3,
"promedio": 6,
"oferta": {
"gen": 5,
"ecas": 6,
"va": 5,
"ca": 5,
"feh": 6,
"esd": 5,
"cia": 4,
"egct": 4,
"rpc": 5
},
"demanda": {
"gen": 5,
"ata": 6,
"ep": 5,
"gp": 5
},
"seguridad": {
"gen": 8,
"ps": 6,
"rn": 8
},
"comunidad": {
"gen": 6,
"h": 8,
"e": 8,
"rse": 6
},
"mercadotecnia": {
"gen": 6,
"ev1": 8,
"ev2": 8,
"ed": 8,
"pp": 6,
"dit": 6
},
"accesibilidad": {
"gen": 8,
"ef": 6,
"st": 6,
"ci": 6,
"cc": 8
}
},
{
"nombre": "Alamos",
"idEstado": 3,
"promedio": "N/A",
"oferta": {
"gen": 4,
"ecas": 0,
"va": "N/A",
"ca": 6,
"feh": "N/A",
"esd": 5,
"cia": "N/A",
"egct": "N/A",
"rpc": "N/A"
},
"demanda": {
"gen": "N/A",
"ata": "N/A",
"ep": "N/A",
"gp": "N/A"
},
"seguridad": {
"gen": 1,
"ps": 1,
"rn": 1
},
"comunidad": {
"gen": 4,
"h": 3,
"e": 6,
"rse": "N/A"
},
"mercadotecnia": {
"gen": 6,
"ev1": "N/A",
"ev2": 6,
"ed": 6,
"pp": 6,
"dit": "N/A"
},
"accesibilidad": {
"gen": 3,
"ef": "N/A",
"st": 3,
"ci": 6,
"cc": "N/A"
}
}
]
}
]
}
];
var estados = list[0].estados;
console.log('before sort: ', _.map(estados, 'nombre'));
var sortedEstados = _.sortBy(estados, function(e){
return _.sum(_.reject(_.map(e.localidades, 'promedio'), function(e){return e === 'N/A';}));
});
console.log('after sort: ', _.map(sortedEstados, 'nombre'));
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |