Fixed Invalid RIE records detection. Added row sorting