Sorting array by custom key.