add secondary sort algorithm