Added sorting by key values from an array