Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Sort a collection and change at data source

(0) ShareShare
ReportReport
Posted on by 178

Hi Guys,

 

Was wondering how to sort a collection and save the results within the actual collection.

 

Example I want to sort collection 'mycol' column 'Type' in alphabetical order. I want the collection to rearrange in this order. 

 

I know how to show it sorted in tables, a gallery, dropdown list etc. Although, I want to rearrange the data at the source which is within my actual collection.

 

Any help is greatly appreciated.

 

Thanks

Categories:
  • Constrictor64 Profile Picture
    Constrictor64 50 on at
    Re: Sort a collection and change at data source

    Yes, this is a much cleaner solution as you don't have a temporary collection laying around taking up memory as well.

  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 145,475 on at
    Re: Sort a collection and change at data source

    Hi @christian12 ,

    You can do it in one action like this

    With(
     {wCol: mycol},
     ClearCollect(
     mycol,
     Sort(
     wCol,
     Type
     )
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Constrictor64 Profile Picture
    Constrictor64 50 on at
    Re: Sort a collection and change at data source

    The easiest way would be to create a temporary collection and then clear collect the results of that back to the real collection.

     

    ClearCollect(myTempCollection, Sort(mycol, Type));
    ClearCollect(mycol, myTempCollection);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,475

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,767

Leaderboard