I am trying to order my list cards but push the zeros to the end. I read a few responses on this here and tried the solution, but it doesn't seem to work.
Please see my linq query below. (ToPackCards is just an extension to map to my custom object)
List<PackCard> packCards = db
.PackCardEntities
.OrderBy(pc => pc.PackNumber)
.ThenBy(pc => pc.PickPosition == 0)
.ThenBy(pc => pc.PickPosition)
.ToList()
.ToPackCards();
My data looks like this
Id|PackNumber|PickPosition|CardId
1|1|null|100
2|1|null|120
3|1|1|134
4|1|2|232
5|1|null|456
I want this to be sorted like this
3|1|1|134
4|1|2|232
1|1|null|100
2|1|null|120
5|1|null|456
What I get is this
1|1|null|100
2|1|null|120
5|1|null|456
3|1|1|134
4|1|2|232
Let me know if I am messing this up somehow, thanks!