query.sort()

Sorts the query based on the column specified and the order criteria given. Modifies the original query object

query.sort( columnNameOrSortFunc [, direction ] )

Returns: Boolean

Argument Description
columnNameOrSortFunc
any, required

a list of names, a single column name or a function used as comparator.

Alias: column_name, columnnames, columnname, name, names, column_names, sort, function, udf, sortFunction, sortFunc

direction
string, optional

a list of directions or a single direction definition (asc,desc), the list must have the same length as the columnName list. ONly used when the second argument defines a list of column names.

Alias: directions, dir

Examples

news = queryNew("id,items",
    "integer,varchar",
    [ {"id":1,"items":"chocolate"}, {"id":2,"items":"juice"}, {"id":3,"items":"vegitable"} ]);
//sort it
news.sort("items","desc");
//dump it
writeDump(news);
news.sort("items","asc");
writeDump(news);

See also