Added sorting algoritm