[SortRecordList] Discussion

[SortRecordList] Discussion

Forge Component
Published on 19 Oct (8 days ago) by OutSystems Labs
16 votes
Published on 19 Oct (8 days ago) by OutSystems Labs

Hi all,

This extension doesn't work with Outsystems 5.0 when the recordlist to be ordered has more than one structure, anyone has fixed it?

Hi Rodrigo,

We'er using the attached extension without problems. Can you try it out.

Hello all.
Also with me the extension SortRecordList with Outsystems platform is not working. It raises an exception "Failed to compare two elements in the array."
Version doesn-t work either.
With version of the extension it works.
I'm using Service Studio
Attached is a simple espace that replicates the problem.


I'm having the same problem. I've just migrated the SortRecordList from 4.2 to 5.0 and it doesn't work anymore. Anyone knows why?

Best Regards,
Nelson Sousa

Hi Nelson,

The extension can't be migrated directly from 4.2 to 5.0 because the Platform's model has changed. Have you tried the extension I've uploaded in a previous post? Does it work with that one?

Hi André,

Yes, I've tried it, and it still sends the same error. Thanks.
It also sends the error attached.

Best Regards,
Nelson Sousa
Hi Nelson,

From your screen shot it seems that you're trying to sort the record list by a column that doesn't exist in it's structure. I'm not 100% sure but if you're sorting using 'ssOrder' as your column try using the attribute's exact name that is probably just 'Order'.

If this fails I suggest you send this information to OutSystems Support. I don't have much information so that I can help you much more.

Hope that this helps you.
Hi André,

That's what I'm doing. I'm ordering it by the name "order". Internally the extension adds the "ss" to the string. "ssOrder" is the name that the variable has in the c# code of the extension.

The column exists in the structure. I had the 4.2 platform and it worked just fine. Now I've converted to 5.0 and it stopped working, with no modifications in the code.

I've already send the information to Outsystems support. Thanks.

Best Regards,
Nelson Sousa
Any one get this working in 5.1 yet?
It works for me if the RecordList is of an entity Type, but if it's from a Structure, it doesn't work.
Hi all,

I've updated this extension to be able to do a multi-column sort, similar to an "order by" clause, by passing it a comma-delimited list of columns to sort by.


Carlos Alfaro
And what about java version?

Your version with the multiple columns sort is a really nice improvement, and working like a charm with 6.0.

There was just one thing that took me a little while to figure out, so I want to share it here, which is that you have to prefix the attribute (column) name with the Entity/Structure name.
In hindsight I guess it was easy to see what I was doing wrong, but it stumped me for a while :-)

Thank you.
Has anyone succesfully used this extension with the List_Navigation widget?
Gonçalo Fonseca wrote:

Your version with the multiple columns sort is a really nice improvement, and working like a charm with 6.0.

There was just one thing that took me a little while to figure out, so I want to share it here, which is that you have to prefix the attribute (column) name with the Entity/Structure name.
In hindsight I guess it was easy to see what I was doing wrong, but it stumped me for a while :-)

Thank you.
Can you give an example to de input on the order by parameter? 
Thank you
I need to put this in the discussion because I always come here to look it up when I forget...

The format for the multi-column sorting is:

"EntityName.AttributeName,EntityName2.AttributeName2" etc.

No curly braces or square braces...

Is there a java version of the multisort?
I don't think the current version is able to sort on attributes in nested structures, or is it? So not just Entity1.Attr1, Entity2.Attr2, but something like Struct1.Attr1.Struct2.Attr2,Struct1.Attr2.Struct4.Attr5 or the like? Since we needed something like that I wrote it myself, and it works like a charm (as far as I've tested, I haven't tested every possible combination), but maybe I overlooked something.
Hi Kilian,

Why not join the team then? :)
Well, I could, but I've basically rewritten almost everything :) I could like some beta-testers though :) Is there a way to add an attachment to a post?

Hi All,

I get an error on my acpt environment when I use the sort record list extension, anybody an idea what could be causing it?

The error I get:

Error: Method not found: 'Void OutSystems.NssSortRecordList.IssSortRecordList.MssSortRecordList(System.Object, System.String, Boolean)'.

Kind regards,

when will it possible to sort the recordlist ascending/descending per attribute.

for example:

entity1.date desc, entity1.name asc
"when will it possible" - when you ammend the extension? :) I've been thinking of allowing that in my version of the extension, but it isn't completely trivial, unfortunately.
Ok, I exaggerated, it was 10 min. work. My version now accepts " asc" or " desc" after the field name to override the default sorting specified when calling sortrecordlist. I've got to rename some variables now for optimal legibility, but I'm confident I can finish that this week, and I'll upload my version as attachment to a post.
Ok, here's my version that can both sort on multiple fields, at any depth in the records, and can also sort ascending and descending. Though it is tested, I can't vow for it to be bug-free, so consider it a beta version if not a release candidate :).

EDIT: Three disclaimers:
1) I'm not a .NET programmer. Though well-versed in C and to a lesser extent C++, my .NET knowledge is wanting. So if I violated any .NET standards or common practices, apologies and please tell it here so I can change it.
2) I haven't coded it for performance, so performance may well be worse than the original version.
3) I've never done anything Java, so no Java version from me, sorry!
EDIT: and a fourth one:
4) We've tested it with structures, but not so much with entity records, so I'm not entirely sure it'll work for those (though it should!)
It seems I can attach only one file at a time, so here's the most important part.

I have a structure with an attribute that's an Integer.
Then I use this structure to construct a List, that is used in a Table Records widget.
Then I apply a List_Navigation widget to the table, and finally I apply this sort extension and try to order from that Integer attribute.
It looks like it works in the first page.
When I start navigating through the table's pages, it's all  unsorted. I don't even see a pattern that would help understand what's happening.

Has anybody used this extension like this before, and had it working?
I would love to hear some ideas...

Thank you


Hi Ana,

In order for this to work correctly, you must first apply the sorting, before the list is used by the Table Records. If you don't, the behaviour depends a few factors, but the outcome will never be what you want (as you experienced).
Hello Kilian

And how should I do that?
The sorting is by user request, when they click on the given column...
I forgot to say I am using the List_SortColumn widget for the sorting, and a custom made action to call the SortRecordList action... And using version 8.

Hi Ana,

You should sort the list, then explicitly assign the list to the TableRecords. I've included a simple eSpace to show how it works (note that normally, you'd not use a separate list when the data comes directly from the database, this is just for showing the principle).
Hello Killian,

Many thanks! I figured what I was doing wrong with your example.

Best regards,
Glad I could be of help, could luck with your project.
Hi all,

We've just started using Outsystems and I have build a list screen using this extension to sort of web service results. I was hoping someone could help in clarifying a sort order issue I'm finding.

When I sort alphas the case of the character is affecting the results eg if we had 3 names of fred, andrew and Keith, then using this extension we either get fred,andrew,Keith or Keith,andrew,fred.

The capital "K" is being sorted as less than "a". Ideally I want the search to be case independant eg andrew,fred,Keith or Keith,fred,andrew. Is this possible ?

Hope this makes sense.

Any help appreciated. Thanks.
Sorting is alphabetically, and capitals sort before lower case. The sorting is not case-independant.

thanks for the quick reply.

I don't think it is sorting alphabetically. it is sorting lowercase first and then upper case.

I downloaded the front end of this extension with the computers entity. I added an entry with a network name of "california". When sorting on network name this appeared first with the original "California" at the bottom. This means lower case are sorted first, followed by upper. I would have expected "california" to be below "California".

Is this the way it is supposed to work ?
Maybe this component needs a case-insensitive sort option to be added?

@Kenneth, are you using the Java version or the .NET version?

@J.Ja: my thoughts as well

forgot to say I'm using the Java version. I'm using outsystems 8.0.1.
Ok, I can't say anything about Java, I only know the .NET version. It seems strange though, the results you are getting.
Thanks for the replies - I have created a workaround which is not idel but does resolve my issue.

I've created a field on my list which is never displayed. When I sort on a particular field eg name, I move that name to this field and convert to uppercase. I then sort on this field rather than the name.

I've done it this way as I have many fields in my list that I want to sort - if there are just a few, I suppose I could have created duplicated columns and assigned these when I get my data back. This would avoid any overheads when clicking on column to sort.

Thanks for you help.
I have four entities in the result list which I want to sort by Table1.Field1,Table2.Field2 and it is not working. I am using platform 9 in .NET environment.
Ali, I don't think the original extension is able to do that. I created a new version that can do that, which I've attached somewhere above. To make it work with version 9, you should change recordList.Data.Sort to recordList.Sort in SortRecordList.cs.
Thanks Kilian,

I thought the version attached to this page was yours. Thanks for correction. And I appreciate your quick response.

Take good care of yourself :)
Hi Ali,

You're welcome. Let us know whether it works.

We are trying to use this extension with Structures in version 9.0 (getting the last stable download of this component) and we are getting the following error previously reported:  "Failed to compare two elements in the array."

Did anyone got the same error?


Best Regards,
Nuno Mendes
That usually means that you are passing in the wrong entity/structure or attribute names to be sorted. It may also mean bad data, not 100% sure on that.

Hi Justin,

We are trying the same exact test with a Entity and it works fine, just a entity with 2 attributes Id (integer) and Desc (text). A structure with Id (integer) and Desc (text) and it gives us the error described.


Best Regards,
Nuno -

Can you send an eSpace with the problem code?

Hello Justin,

You can access the test right on my personal environment acessing the URL: https://mendes.outsystemscloud.com/SortTest/Sort.aspx

I attach the eSpace too.

Thanks for the help.

Best Reggards,
Nuno -

Your "sortBy" parameter is wrong, as expected.

It needs to be in the form of:


For example:




The "Nr" is going to fail.


How do I sort by a column that is in a record within a structure?  Example eSpace of what I'm trying to do is attached.

Hello Josh,

I don't believe there is a direct way to do this with SortRecordList.

What you can do is add an extra attribute to the structure, based on the content of the record, and do the sorting on this new attribute.


  • First Name
  • Last Name
  • ...
  • Record
  • SortAttribute = FirstName + " " + LastName

I wasn't able to download your sample eSpace, so I'm not sure this approach is suitable for you.

Joshua Austin wrote:

How do I sort by a column that is in a record within a structure?  Example eSpace of what I'm trying to do is attached.


How's it going?! Nice to see you around and trying stuff :)

To sort by the event name, do the following:

Pedro Cardoso

Hi Joshua,

If the advise above doesn't work out for your usecase, you can always pick up my version, which can sort fields in nested structures to indefinite depth. I've attached the latest one to this post. (I also think my code is a lot cleaner than the original one, but hey, judge for yourself :))
Using Pedro's "x.y" instead of "{x}.[y]", with Kilian's latest SortRecordList version, combined with converting my data source from a list to a record list did the trick.  Thanks, guys!!!

Good to see you too, Pedro!  I'm doing great!  Planning to take the exam for Professional OS certification soon.
Glad I could be of help.
Hello there.

I'm using service studio version and I'm getting the same error as @Mendes.

I have created a structure "SkillsPercentage" with two atributes "Name" and "Value" as you can see in attachment. Then I created 2 local variables, "SumOfSkillsPercentages" that is a list "SkillsPercentage List" and "SkillPercentageSum" (type "SkillsPercentage"). "SumOfSkillsPercentages" is created by appending n "SkillsPercentageSum".

Now I want to sort by "Value" the SumOfSkillsPercentages" but I'm getting the error and seems it's all well. Do you have any idea what is wrong? 

Thank you for your time, I really appreciate. 
The "sortBy" parameter should be the _name_ of the attribute you want to sort by, so you should use the string "Value".
Hi there again and thank you.

I tried it already and I have the same error.
I've downloaded the espace that Mendes provided above.
SortRecordList does not seem to work with variables of type "List". You _must_ use a variable of type "Record List".
In the espace provided by Mendes, the sort of the entity works because the variable used is the result of an aggregate. The sorting by structure does not work because a "List" variable (to which the elements are appended) is being used.
Alright. So any tip to solve this?

Thank you.
Tiago Bernardo wrote:
SortRecordList does not seem to work with variables of type "List".
Variables of this type are completely different internally, and difficult to handle in an extension (not to mention completely undocumented). So yeah, they don't work.

What do you mean exactly? Do you also use a List of type instead of a Record List? In that case, change your input to a Record List.
Tip: Your variable "SumOfSkillsPercentages" instead of being of type "SkillsPercentage List" must be of type "SkillsPercentage Record List".
Well, my bad. Didn't see the "record".

Worked now :)

Thank you Tiago and Kilian.
Hi Fernando and Tiago,

The latest version now supports the List data type, kudos to Hugo Lourenço for that overhaul!!
That's very cool, I'll give it a look and see if I can integrate that in my version.