I programmed this little ‘gem’ a bit of time ago:


static Int16 asciisort(char* s1, char* s2)
{//recursive ascii sorter for SysQSort
//FIXME: fails if both strs are exactly the same
//0...p1==p2
//-1.p1 < p2
//1...p1 > p2
if(*s1< *s2)
{
return -1;
}
else if(*s1>*s2)
{
return 1;
}
else
{
return asciisort(++s1,++s2);
}
}

Don’t ask me why I did it recursively, but it was the easiest way to code it(imho). The code breaks when two filenames are exactly equal, but well, this rarely happens…

Related posts:

  1. On defining multiple pointers in one line
  2. Globals in DAs
  3. With the Speed of the ARM
  4. Debugging with decoy printfs
  5. Fix padding issues in structs

2 Responses to “Sorting filenames in a recursive manner”

  1. Exactly what StrCompareAscii does. So why do you write your own?

  2. Hi Henk,
    because:

    a)I didnt have the API reference open while coding

    b)Because I was bored

    c)Because I was interested to do it myself

    To be honest, I have no idea anymore though!

    Best regards
    Tam Hanna

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting

© 2013 TamsPalm - the Palm OS / web OS Blog Suffusion theme by Sayontan Sinha