Added sorting for flagged.