Was this page helpful?

List.Orderby

  • We have highlighted your search term list.orderby for you. If you'd like to remove the search term, click here.
Table of contents
  1. 1. Usage Restrictions
  2. 2. Parameters
  3. 3. Result
  4. 4. Samples
List.Orderby(list : list, keys : any) : list

Sort items in list of maps using key names.

Usage Restrictions

9.02 or later.

Parameters

Name Type Description
list list list value
keys any key name or list of key names; sort direction is controlled by appending " ascending" or " descending" to the key(s); when omitted, the direction is asending by default

Result

A new list of maps sorted by the specified keys

Samples

   Output

Sort a list of maps in different ways

var unordered = [
    {Name: "Foo", Price: 5},
    {Name: "Bar", Price: 7},
    {Name: "Zoop", Price: 6} ];

var ascendingPrice = list.orderby(unordered, "Price ascending");
<b>"Ascending by Price:"</b><br/>;
foreach( var item in ascendingPrice ) {
    item.Name; " => "; item.Price;<br/>;
}

var descendingName = list.orderby(unordered, "Name descending");
<b>"Descending by Name:"</b><br/>;
foreach( var item in descendingName ) {
    item.Name; " => "; item.Price;<br/>;
}  
Ascending by Price:
Foo => 5
Zoop => 6
Bar => 7
Descending by Name:
Zoop => 6
Foo => 5
Bar => 7
Was this page helpful?
Tag page
You must login to post a comment.

Copyright © 2011 MindTouch, Inc. Powered by