Move IList<T> item to top

Found myself in need of moving an item stored in an IList to the top of the stack. Some IList methods like RemoveAt() and Insert() would work however wouldn’t be as efficient with a large data set. Fortunately found a Stack Overflow post which would do the move in a single step. I renamed the extension to MoveToTop and here’s a quick and easy Xamarin Workbook sample.

Output:

Id: 3 Name: Third
Id: 1 Name: First
Id: 2 Name: Second

Hope someone finds this useful. Feel free to share/like etc.

Principal Software Engineer at Command Health https://github.com/dannycabrera

Principal Software Engineer at Command Health https://github.com/dannycabrera