If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.
I see your point, however I try to keep interfaces as simple as possible - and with this the number of (required) parameters as small as needed. Old habbit of a lazy programmer who hates to look up APIs...
I'm with you. I'd rather have a few smaller functions than one catch-all function.
With PHP you can overload a function and preset defaults; that way you only need to specify something if it's outside the norm. With MivaScript, You can't do that. So it's better to make one function for ascending sort, and another for descending. Admittedly, this means twice the code to debug, but the nice thing about these kind of functions is that once they're done, they're done.
The alternative is to make "header" functions. Functions that are named distinctly, but call the parameter-heavy, work-horse function with all the bells and whistles established.
So you have a Sort_Asc(l.data) and a Sort_Desc(l.data), but they call Sort('A', l.data) and Sort('D', l.data) respectively. Sort() is your catch-all function.
As for "numbers"... To simplify the whole numbers versus strings issue, why not make a single isdigit() call and if true, padl() to say 10 digits with '0's. So all strings gets sorted as is, all numbers get sorted up to 10 significant digits, and if you have a mixture, they will still be sorted correctly. Or was this already discussed and I missed the post?
I guess everyone else knows about it or doesn't need it, but this is the BEES KNEES to me. Since I code in Mivascript about 4% of my time, it is a HUGE timesaver. THANKS!!!
Gordon Currie Phosphor Media - "Your Success is our Business"
Comment