Add secondary sorting for lists to prevent equal valued element constantly swapping position