select customer_id, ; MyFunc(customer_id) myNewField ; from Customer ; where customer_id in (16, 10, 12, 15, 8, 1) ; order by myNewField ; into cursor curCustormer Function MyFunc(tnCustomer as Number) Do Case Case 16 Return 0 Case 10 Return 1 Case 12 Return 2 Case 15 Return 3 Case 8 Return 4 Case 0 Return 5 OtherWise Return 100 EndFuncIn this approach when you need modify the values, you can change your UDF instead of the Select statement. I think this mode is more slow than IIF(), but maintenance is more clear and speed.