I’d like to sort a text field but not in alphabetical order. For example, I want a field named ‘priority’ with values of High, Med, or Low ordered such that High is first and Low last.
I’d like to create a method that knows how to sort each field and just call it as a parameter in the sort command. I’ve played with this a bit but I’m not having any luck. Here’s an example of the kind of thing I have tried.
Here’s the sort method:
// sort that uses a special text sort method
controller.sort('TextSrt(priority) asc');
Here’s the TextSrt method:
// determines a custom sort order number for text fields
switch (arguments[0])
{
case 'High': srt = 1;
break;
case 'Med': srt = 2;
break;
case 'Low': srt = 2;
}
return srt;
When I try this, the sort doesn’t seem to execute the method. Is my syntax wrong or does sort simply not support this?
Yes, I could add a sort order column and compute a custom sort order easy enough, but I have many of these, and it is less flexible, time consuming and requires more maintenance to use all these extra columns.
Any clues appreciated.
Bob