order statistics code