sort func fix