I want to sort a set of data that is not in an entity by multiple columns. For this case consider two columns: Reviewed and Price. I want Reviewed = True rows to be sorted to the bottom of the list while the sort order of Price is set by the system admin.


SortRecordList allows for the intake of multiple columns, but it only specifies the boolean for ASC. So if I set that to False, my Review records appear at the top of my list instead of the bottom.


A similar question was added onto a post, but was not answered: https://www.outsystems.com/forums/discussion/21343/multiple-attributes-sort-on-listsort/#Post207505


Another similar post got this answer: https://www.outsystems.com/forums/discussion/48324/sorting-grouped-columns-with-static-and-dynamic-sorting-at-same-time/#Post177639


I need suggestions on how to tackle my problem and this could be more broad than my use case. I really want to know how to sort one column ASC and another DESC at the same time in a list.

Hi Eric,

I don't think there's a lot of tools available to perform the logic you're looking for - there might be some Javascript libraries that would give you this out of the box in a Table element, but I assume you're looking for a server-side solution.

SortRecordList limits the Ascending/Descending parameter to one option like you mention, and the base ListSort is just as restrictive.

While it's usually not the first choice, this sort of more esoteric logic looks like a good candidate for an Extension.

Your use case looks like a LINQ one liner too. You'd have to rewrite it to make it a little more generic, but it should be doable.

Hi Eric,

What you expect is something like that?


Solution

I have created a WebScreen with the following structure:

Here my Preparation to simulate your list:

And then, my ScreenAction OnChange event for that CheckBox:

As you can see, I added two columns to set a value to represent the order I want, combining the columns Reviewed and Price (a trick).

I hope this is what you want!

Solution


In addition, use a better function to format the Price column in order to obtain a string for the correct classification, perhaps including ZEROs at the beginning (00020.00, 00340.00 etc).

(at Assign while cycling MyList - see Preparation)


Hi Eric,

Please, if you liked any suggestion here, mark It as solution. If not, let us know to help you!

Wilbert Carpi wrote:

Hi Eric,

Please, if you liked any suggestion here, mark It as solution. If not, let us know to help you!

I will try this out and see where I get. I am on reactive so there will be some differences but hopefully nothing major.


Thanks


Wilbert Carpi wrote:


In addition, use a better function to format the Price column in order to obtain a string for the correct classification, perhaps including ZEROs at the beginning (00020.00, 00340.00 etc).

(at Assign while cycling MyList - see Preparation)


This was the solution I was considering, but I wanted to see if there was an extension out there similar enough to modify for my use case. It doesn't seem like there is, so I will have to create a "SortOrder" column on data retrieval.


Thanks