I have a list class that implements IEnumerable<T>
.
Type T is a complex class with a string member as unique identifier. But it's enough to take just int as element type for explanations.
I want to move multiple items one step to left.
Example:
Original list: 0, 1, 2, 3, 4, 5
Now all bold items (0,3,4) should be moved to left (as far as possible).
Result list: 0, 1, 3, 4, 2, 5
Is there a good algorithm to do that? Maybe just with LINQ.
Edit: Answers for a List<T>
list are welcome. My class has similar methods. (Thanks for hint by TylerOhlsen.)
Edit2: One selected item should not pass another selected item.