How to sort a list of integer

In Outsystems, is there a way to sort a list of integer not in database? I am not able to use the SortRecordList.
Hi Robin,

Why are you "not able to use the SortRecordList"? Is it the problem that you don't know how to use SortRecordList, or is there another reason you can't use it?
Hi Kilian,

Yes I can use SortRecordList, but it seems to only work for Entity Record List.

I could not get it to work directly for basic integer list nor other structure list.

Currently this is my approach if I were to use "SortRecordList"
  1. Convert the Integer List to any Entity Record List (like User's Entity Record List)
  2. Use SortRecordList to sort it
  3. Convert the Entity Record List back to Integer List

Are there any better way to do sort operation for integer list and structure list?
Hi Robin,

Platform 9 introduced something called a "simple list", which is a list of primitives (like integer or text) or structures (either entity structures or normal ones). Before that, we only had a "record list", which is a list of records. A record is like a container, that can hold one or more structures (of either type), but not primitives.

Extensions that deal with lists worked only on record lists - the new simple lists were not supported out of the box. The reason behind that is that a platform record list in Java or C# is a bit different from a platform simple list, so extensions need to be specifically coded to also handle the new simple list (which isn't helped by the fact that there is no official documentation explaining how they work).

That said, iirc, the SortRecordList extension was updated a while ago to handle simple lists, so they should work I think. If not, I'd ask a question in the component's specific forum section.
Btw, I don't know how you're converting, but you should be able to that with a single ListAppendAll.
Hi Robin,
if you are not able to use the SortRecordList. then you can create your own logic. for example

Create a duplicate list of same type, by using the loop find the maximum/minimum value in a variable from integer list and apend it into the duplicate list.

Rajenra Singh

Hi Rajenra,

I'm sorry to say, but that's bad advice. For one, reinventing the wheel is never a good idea. Secondly, what you propose will be so dreadfully slow (it's basically bubble sort, but worse), it'll be unworkable for large lists.
Hi Kilian,
             I know its a bad advice, it just a option when list is not too large and you are not comfortable with
sortrecordlist widget. after all internally widget is doing the same thing.


No, sort record list doesn't do "the same thing". Sort record list uses .NET and Java sorting algorithms. Not some primitive bubble sort.
 Hi Kilian, i know it uses .net and java algo..but i mean in terms of logic not tech.

Yeah, but not all logical equivalent solutions are technically equivalent. You proposed a technically inferior solution, and I said that was bad advice. I stand by my words.