ListSort vs SortRecordList - sort by passed as text

ListSort vs SortRecordList - sort by passed as text

  

Hi,


I have an action which passes the orderBy on a structure/entity as text, because it's coming from a webservice.

So currently I am using SortRecordList to sort it.

Would it improve to use ListSort (and how to tackle the Order by, with a "silly" mapping text to <object>.attribute ???)

advantage is that i have no more use for sort-recordlist and one less dependency :D





Hi J.,

I think the main advantage of using ListSort in this case is to have one less dependency, as you say, but there's the disadvantage of having to code the "switch" logic to decide which attribute should be the criteria.

If all the attributes are of the same type, the "switch" logic can be written inside the BY parameter directly. e.g.

If(AttributeName = "FirstTextAttribute",
    FirstTextAttribute,
    If(AttributeName = "SecondTextAttribute",
        SecondTextAttribute,
        ...))

If the attributes are of different types, you can adopt the same strategy but you need to convert everything to Object to ensure the right sorting criteria is used. e.g.

If(AttributeName = "TextAttribute",
    ToObject(TextAttribute),
    If(AttributeName = "IntAttribute",
        ToObject(IntAttribute),
        ...))

Cheers,

Paulo

Isn't it true that OutSystems recommends using ListSort and that SortRecordList should be avoided? It was mentioned in one of the OutSystems courses I took.