I have a unique sorting problem in which I have an array of objects that are given to me in "order" but the order is not known to me or sorted on any particular property on the object.
The object is as follows
public class Case
{
public virtual int Id { get; set; }
public virtual string PalletId { get; set; }
}
What I need to do is take this array of Cases
s that I'm given and create a new list of these objects that is sorted by the relative order of the original collections PalletId
field then by it's id field. It is not an absolute ordering on this field though because it's relative to the original order of the collection.
For example:
Original Collection
Id ---------- PalletId
1 ----------- 5
2 ----------- 6
3 ----------- 4
4 ----------- 5
5 ----------- 6
6 ----------- 4
Sorted Collection
Id ---------- PalletId
1 ----------- 5
4 ----------- 5
2 ----------- 6
5 ----------- 6
3 ----------- 4
6 ----------- 4
The sorted collection above represents how I need to sort these. Notice how the palletid's in the sorted collection are not in ascending or descending order but they are sorted by the order in which you see them in the original collection (5, 6, 4). Within each pallet id I have to sort the id field in that same order. So it's the order in which I see the Id field in the original collection for a particular pallet id.