If you really want to maintain the order of numbers that are equal you'll probably want a different sorting function. The documentation I found for qsort states:

If two members compare as equal, their order in the sorted array is undefined.

Jim