finscn/LinkedList — pull request #2 by html5solo (2012-09-18 05:19:56+00:00)
Title: Update LinkedList.js

给linkedlist添加了sort方法，用于元素的简单的重新排序。

/* 测试例子：请查看console */
(function() {
var data1={id:"5", ak:"900", name:"zoo"}
, data2={id:"2", ak:"100", name:"foll"}
, data3={id:"7", ak:"300", name:"about"}
, data4={id:"3", ak:"320", name:"bomb"}
, data5={id:"8", ak:"950", name:"excellent"};

var linker = new LinkedList();
linker.addNodes(data1, data2, data3, data4, data5);

console.log('old:');
console.log(linker.toArray());

linker.sort();
console.log('sort ASC :');
console.log(linker.toArray());

linker.sort('ak', true);
console.log('sort by "ak" DESC :');
console.log(linker.toArray());

linker.sort('name');
console.log('sort by "name" (string) ASC :');
console.log(linker.toArray());
})();