Originally Posted by
helloworld922
This looks almost exactly like the merge sort algorithm.
Merge sort - Wikipedia, the free encyclopedia
The main part you need is the merge function. It takes 2 lists that are in sorted order (from you're description it looks like you'll need to sort those two lists first, use which ever method you like best), then goes through each list, remove the smaller (or larger, depending on if you're sorting lower-to-higher or higher-to-lower) of the two elements at the front of the lists, then add that element to the front of your new list. Repeat until both lists are empty. If one list is empty, you can "dump" the remaining sorted items in the other list into the end of your new list.
A lot of that looks like foreign language to me and I was wondering if their was any way I could do it in just a quick for loop, as I posted shortly after you.