1

(1) In my Canvas App I create a collection like this:

Collect(colShoppingBasket; {Category: varCategoryTitle ; Supplier: lblSupplier.Text ; ProductNumber: lblProductNumber.Text });;

It works - I get a collection. And whenever I push my "Add to shopping basket" button, an item are added to my collection.

(2) Now I want to sort the collection and then use the sorted output for other things.

This function sorts it by supplier. No problems here:

Sort(colShoppingBasket; Supplier)

(3) Then I want to display the SORTED version of the collection in various scenarios. And this is where the issue is. Because all I can do is manipulate a DISPLAY of the collection "colShoppingBasket" - (unsorted).

(4) What would be really nice would be the option to create and store a manipulated copy of the original collection. And the display that whereever I needed. Sort of:

Collect(colShoppingBasketSORTED; { Sort(colShoppingBasket; supplier) });; <--- p.s. I know this is not a working function
ToFo
  • 1,643
  • 1
  • 19
  • 34

1 Answers1

2

You could use the following:

ClearCollect(colShoppingBasketSorted, Sort(colShoppingBasket, Supplier))

Note that it is without the { }

This will Clear and Collect the whole colShoppingBasket sorted.

If you want to store the table in a single row in a collection, you can use

ClearCollect(colShoppingBasketSortedAlternative, {SingleRow: Sort(colShoppingBasket, Supplier)})

I wouldn't recommend this though because if you want to use the Sorted values you'd have to do something like this:

First(colShoppingBasketSortedAlternative).SingleRow -> this returns the first records of the colShoppingBasketSortedAlternative then gets the content of the SingleRow column, which in this case is a Collection

Note: You will need to replace the , with ; to work on your case

Murilo Santana
  • 615
  • 1
  • 7
  • 13