Any best or effective sorting algorithm, to sort list of the sprite by user define order index?
There is no best-for-all-situations.
What’s wrong with Array.Sort / List.Sort ?
Yea, the built-in sort for List uses a Q-Sort I think, which is pretty fast. Probably ok to just use that until you decide it’s not fast enough, then you can explore other options.
(I pass along this advice as someone who has, in the past, been known to get too side tracked implementing optimal algorithms for stuff I probably didn’t end up needing :D)
I felt that
Have you tried IComparable?
Always do the most clean code solution until you get proof of it being not fast enough. I would make a wrapper class containing the sorting field and the sprite reference and use linq to objects:
var sortedList = spriteList.OrderBy(item => item.SortIndex);
Using list.Sort() will work too but will require more work to get it to sort using that arbitrary sort field. So, thats more code than needed, untill proven otherwise