leora
leora

Reputation: 196831

custom string sorter

I want to sort a collection by one of the properties which is a string, but i dont want to sort alphabetically.

Here is my code

 IEnumerable<Item> items = Repository.Query<Item>().OrderBy(r=> r.Status)

Status is a string but i want to sort in a particular order (not alphabetically)

how do i inject a custom sorter in the above syntax.

Upvotes: 3

Views: 263

Answers (1)

Itay Karo
Itay Karo

Reputation: 18306

Order by has an overload that takes IComparer.
Take a look here.

Upvotes: 7

Related Questions