Reuse comparator between sort invocations

Change-Id: Ic7b36c76424a910df6f958ce468d58aef6bcd1fd
Signed-off-by: Robert Varga <rovarga@cisco.com>