listitems
をsortList[0]
またはsortList[1]
でソートするにはどうすればよいですか?
例:http://jsfiddle.net/wmaqb/20/Jquery sortable - ソートリストのマニュアル
HTML
<div id="sortable">
<div id="sort_18b0c79408a72">Berlin</div>
<div id="sort_dkj8das9sd98a">Munich</div>
<div id="sort_skd887f987sad">Browntown</div>
<div id="sort_54asdliöldawf">Halle</div>
<div id="sort_f5456sdfefsdf">Hamburg</div>
</div>
<input id="sortList0Bt" type="button" value="sortList0" />
<input id="sortList1Bt" type="button" value="sortList1" />
JS
sortList= new Array();
sortList[0] = {};
sortList[0]['18b0c79408a72'] = 6;
sortList[0]['dkj8das9sd98a'] = 9;
sortList[0]['skd887f987sad'] = 3;
sortList[0]['54asdliöldawf'] = 1;
sortList[0]['f5456sdfefsdf'] = 5;
sortList[1] = {};
sortList[1]['18b0c79408a72'] = 1;
sortList[1]['dkj8das9sd98a'] = 2;
sortList[1]['skd887f987sad'] = 3;
sortList[1]['54asdliöldawf'] = 4;
sortList[1]['f5456sdfefsdf'] = 5;
$("#sortable").sortable();
$('#sortList0Bt').click(function() { sortIt(sortList[0]); });
$('#sortList1Bt').click(function() { sortIt(sortList[1]); });
JS - ソート機能
function sortIt(sortList)
{
var mylist = $('#sortable');
var listitems = mylist.children('div').get();
listitems.sort(function(a, b)
{
// --------------- >>> HERE <<< --------------
});
$.each(listitems, function(idx, itm) { mylist.append(itm); });
}
ありがとうございます!