Seems like you are looking for a sorting algorithm, try Insertion Sort: http://en.wikipedia.org/wiki/Insertion_sort It's of quadratic cost, but easy to understand and implement and fast enough for 10 entities.
"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual