[Core] Add a sort option (fixes #6).