Setup ext sort function