Let's say if we are sorting some records by a number in record:
Name Number_of_Language_Known
John 3
Mary 2
Peter 3
Mike 1
...
If we are not also sorting by Name
, then the order of John and Peter is not guaranteed, but it shouldn't be random if the records never changed? I think it should be true in most environment (that is, nothing else changed, and the sorting is done twice).
That is, if we sort it one time, it won't be Peter before John and the second time, John before Peter.
This is because in a Ruby on Rails environment, if the records are fetched from DB and then sorted by a Ruby function, and printed as the original page content, the order is one way, but if the data is requested through AJAX afterwards, then the sorted array elements can have a different order, for records with the same number in that number field, and that seems strange.
Update: if the data is from the db, then maybe the db can have unpredictable order when records are fetched. But what if the records are sorted by primary ID in the first place? Also if the data is right inside the data structure already, I don't know any common sorting algorithm that will produce different sorting order each time. That is, order not guaranteed but not random.