반응형
jQuery
-
jqeury로 json 정렬하기프로그래밍/Etc 2018. 10. 31. 17:24
참고: https://stackoverflow.com/questions/881510/sorting-json-by-values jquery로 json 파일 정렬하는 법 prop 은 정렬하고 싶은 json 파일의 필드 이름이고 asc는 순차 정렬 여부를 의미함. function sortResults(result, prop, asc) { SortedResult = result.sort(function(a, b) { if (asc) { return (a[prop] > b[prop]) ? 1 : ((a[prop] a[prop]) ? 1 : ((b[prop] < a[prop]) ? -1 : 0); } }); return Sort..