refactored sorting to rants helper function