Trying to see what's going on with 10 items can be a little hard. It's a lot easier to debug the problem if you find the smallest possible case where it doesn't work. I.e.
Does it work with 0 items? (sometimes that even crashes)
Does it work with 1 item?
Does it work with 2 items that are in the correct order?
Does it work with 2 items that are not in the correct order?
Does it work with 3 items...