java - Does Collections.sort respect the index among the tied inputted elements? (Sorting Stability) -


for example if sort list<individual> 10 people individual::age, , input alice(3), bob(5), , charles(3), output alice(3), charles(3), bob(5) or possible alice , charles being swapped in way outputed in different sequence inputed?

edit:
seems property has proper name: https://en.wikipedia.org/wiki/sorting_algorithm#stability

to quote the documentation:

this sort guaranteed stable: equal elements not reordered result of sort.

for purpose, alice , charles equal (as have same age). calling sort guaranteed keep relative order, , alice appear before charles.


Comments