ksort pseudocode tweaks; definitions for sorting criteria and ktree