発生頻度で並べ替えたい値の配列があります。今のところ、発生を数えることはできますが、それらを並べ替える方法がわかりません...何が問題なのですか?
<script>
$(document).ready(function() {// graphs and prefixes defined here
var list = new Array();
$.getJSON('data.json', function(data) {
$.each(data.results.bindings, function() {
$.each(this, function(k, v) {
if(!($.trim(v.value) in list)) {
list[$.trim(v.value)] = 0;
}
list[$.trim(v.value)] = list[$.trim(v.value)] + 1;
});
});
list.sort(function(a, b) {
return a.value - b.value;
});
var c = 0;
for (var i in list) {
var html = '<li data-value="'+list[i]+'">'+ (c++) +' '+i+' ( '+list[i]+' )';
$("#list").append(html);
}
});
});
</script>