Added sorting function and menu option.