Give us feedback
sortrecordlist
Service icon

SortRecordList

Stable version 3.2.0 (Compatible with OutSystems 11)
Other versions available for 10 and Older
Uploaded on 22 December 2022 by 
SortRecordList Team
4.7
 (25 ratings)
sortrecordlist

SortRecordList

Documentation
3.2.0

About

SortRecordList is an asset that can be used when the System actions ListSort and ListDistinct are too limited. ListSort can only sort on a single attribute, and ListDistinct can only remove exact duplicates. In contrast, the SortRecordList action can sort on multiple attributes, and DistinctRecordList allows specifying the attributes to compare (instead of all attributes like ListSort).


Actions

SortRecordList


Input parameters

  • RecordList - The list or record list to be sorted. Use ToObject() to convert it to an Object;
  • SortBy - The attributes to sort the list by. Specify the full path of the attribute, as you would in Service Studio. Add asc or desc (or shorthand a or d) to sort ascending or descending respecitvely. Multiple attributes should be seperated by a comma. See below for examples.
  • IsAscending - If True, attributes in the SortBy list without a sort order are sorted ascending, if False, descending.


Output parameters

None. The input RecordList is sorted in place.


Examples

  • Given a structure with two attributes, "Number" and "Text", the following will sort Number ascending, and Text descending: Number,Text desc (assuming IsAscending is True).
  • Given a record list with two structures MyStruct and YourStruct, the former with attributes "MyInt" and "MyText", the latter with attributes "YourInt" and "YourText", and IsAscending set to False, the following will sort MyStruct.MyText descending, YourStruct.YourInt ascending, MyStruct.MyInt ascending, and finally YourStruct.YourText descending: MyStruct.MyText,YourStruct.YourInt asc,MyStruct.MyInt asc,YourStruct.YourText


DistincRecordList


Input parameters

  • RecordList - The list or record list that's to be checked for duplicates. Use ToObject() to convert it to an Object;
  • CompareBy - The attributes to compare for equality. Only the specified attributes are checked.


Output parameters

  • OutputList - A list with the same elements as the input RecordList, in the same order, but with duplicate records removed.


Usage

For examples of its usage refer to the demo app. The demo app (from hereon referred to as "demo") shows a table that's sorted on several attributes:

It is possible to clone (duplicate) a computer by Clicking the Clone button. Using the "Create New Computer" button, you can enter a new computer:

For demonstrating the SortRecordList action, a number of buttons are available:

Clicking one of the buttons will order the table by the specified attribute. The last button orders the table by both the CPU and Memory attributes.

For demonstrating the DistinctRecordList action, there is one button available:

Open the demo module in Service Studio to study the way the actions are used.