cracker
cracker

Reputation: 4906

How to change the order of the list?

I have below list:

enter image description here

Where i want to show all the records which contains Status equals to 6 at the last of the list. (*The status would be any starting from 1 to 20 for different properties.)

How can i do this?

Upvotes: 0

Views: 250

Answers (3)

har07
har07

Reputation: 89305

If I understand this correctly, you can use OrderBy() in the following way so that items with Status == 6 are returned after the other items :

OrderBy(o => o.Status == 6 ? 1 : 0)

Upvotes: 3

KARAN
KARAN

Reputation: 1041

use below code i think that will help you. and replace with your property you wan't that thank you.

LastOrDefault(x => x.property).where(x.status ==6)

Upvotes: 0

Mukesh Kalgude
Mukesh Kalgude

Reputation: 4844

You have list of items and you can show last record of this list. It should be use LastOrDefault function.

Upvotes: 0

Related Questions