Fix bug if there are no CDS found

The CDS sort should be caled only if CDS records are found.