This is an old revision of the document!


sort

Sort an Array.


Syntax


Parameters

  • Array subject - The Array to sort.
  • Boolean reverse - Whether to reverse the sort.
    • false (default) - subject will be sorted from lowest to highest.
    • true - subject will be sorted from highest to lowest.
  • Number type - Array key options.
    • 0 (default) - Sort by item values, and re-assign keys.
    • 1 - Sort by item values, and preserve keys.
    • 2 - Sort by item keys.
  • Number method - Sort method options.
    • 0 (default) - Compare items normally, without changing type.
    • 1 - Compare items numerically.
    • 2 - Compare items as strings.
    • 3 - Compare items as strings, using case-sensitive natural ordering.
    • 4 - Compare items as strings, using case-insensitive natural ordering.
    • 5 - Compare items as strings, based on the current system locale.


Result

  • Array - The sorted Array.

Returns subject sorted in order according to various options.

Natural ordering cannot be used with key preservation (when type is 1) or sorting by key (when type is 2), so type will be forced to 0 in this case.

~~DISCUSSION~~

ptpscript/functions/sort.1148744302.txt.gz · Last modified: 2006/06/14 10:26 by dan
 
 
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki