Looping over stable hash sort