Resort records into ranked results order

Added test to ensure records returned in results order

Indentation