This version is out of date, covering development from v5.0.0 to v5.12.2. It is maintained here only for inbound reference links from elsewhere.

Jump to the current version of aTbRef.

Tinderbox Icon

List.nsort([$Attribute])


Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Altered: 

 Function   [other Function type actions]

 Item   [operators of similar scope]

 Data manipulation   [other Data manipulation operators]

 5.8.0

 


List.nsort()

The basic form

$MyList = $MyList.nsort() 

$MyList = $MyList.nsort().reverse() 

This function re-sorts the referenced list in ascending numerical sort order. This means sorting '1,2,11' not 1,11,2' such as occurs with sort() and a lexical sort. A numerical sot is really only useful for numerical data. For text, consider List.sort() or List.isort(), both of which give lexical sorts of differing case sensitivity. Or, use the optional long from (below) and let the nominated attribute's data type set the form of sort, e.g for date sorting.

The resulting sort order can be reversed overall by chaining the List.nsort() and List.reverse() functions.

List.nsort($Attribute)

In this optional extended form there is a requirement that the referenced list is a list of notes names or paths, i.e. $Path data or $Name data where note names are all unique. In such a case, the sort order can be based on a stipulated $Attribute name.

$MyList = $MyList.nsort($Name) 

$MyList = $MyList.nsort($MyString) 

$MyList = $MyList.nsort($Name).reverse() 

In this long form usage, the sort ordering is based on the data type of $Attribute:


Possible relevant notes (via "Similar Notes" feature):


A Tinderbox Reference File : Actions & Rules : Operators : Full Operator List : List.nsort([$Attribute])