The code is linked here : http://ideone.com/eba7CBI cant seem to find the error. Any help and criticism is appreciated.
Why do you think there is an error in your code? It is probably not the most elegant nor a pythonic implementation, but it seems to sort correctly.