sorting endpoints for consistent ordering