我正在嘗試製作我的博客文章的動態列表。我需要列表按字母順序顯示。目前的代碼工作正常,但給了我一個時間順序列表。我如何按字母順序排列我的列表。目前的代碼如下。這是博客博客,我用kimonolabs來製作這個代碼中使用的API。飼料是傑森。 (在博客頁面區域,我首先創建了一個空白html列表,然後使用下面的代碼插入數據,同時給出了Html。)我應該怎麼做才能使結果按字母順序排列。按字母順序排序jquery結果
jQuery.ajax({
"url":"https://www.kimonolabs.com/api/djwmp1p8?apikey=P1DP0fILX0ou5GnXR6DRbbRmkFuQNC0G",
"crossDomain":true,
"dataType":"jsonp",
//Make a call to the Kimono API following the "url"
'success': function(response){
// If the call request was successful and the data was retrieved, this function will create a list displaying the data
jQuery(".panel-heading").html(response.name);
//Puts the API name into the panel heading
var collection = response.results.collection1;
for (var i = 0; i < collection.length; i++){
// Traverses through every element in the entire collection
jQuery(".list-group").append('<li class="list-group-item">' +'<a href='+collection[i].property1.href +'>'+ collection[i].property1.text + '</a>' +'</li>');
// adds the text and the links from the first property into the list
}
}
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<div class="container padding">
<div class="panel panel-info">
<div class="panel-heading"></div>
<ol class="list-group">
</ol>
</div>
</div>
有你看着http://stackoverflow.com/questions/881510/sorting-json-by-values –