Changed order of comparing
Added sorting to save