Add stable_sort functionality to ruby