Skip to content
uupaa edited this page Aug 1, 2015 · 6 revisions

Namespace

Sort オブジェクトは、WebModule 名前空間以下に配置(WebModule.Sort)されています。

Sort.js を読み込む前に WebModule.publish = true; を行うと、 Sort オブジェクトを GLOBAL 名前空間以下に直接配置 できます。

API

var Sort = {
    "nat":          Sort_nat,       // Sort.nat(source:StringArray, ignoreCase:Boolean = false):StringArray
    "number":       Sort_number,    // Sort.number(source:NumberArray):NumberArray
    "random":       Sort_random,    // Sort.random(source:Array):Array
};

Sort.nat

Sort.nat(source:StringArray, ignoreCase:Boolean = false):StringArray は、文字列を人間からみて自然な順番にソートします。

var source =                      ["document", "document new", "document 2013-12-31", "document new new", "document 2013-12-31 new"];
var sorted = Sort.nat(source); // ["document", "document new", "document new new", "document 2013-12-31", "document 2013-12-31 new"]

Sort.number

Sort.number(source:NumberArray):NumberArray は、source を昇順にソートします。

Sort.number([3, 1, 2]) // [1, 2, 3]

Sort.random

Sort.random(source:Array):Array は、source をランダムソートします。

Clone this wiki locally