C/GCC - Is it possible to sort arrays using preprocessor?

Posted by psihodelia on Stack Overflow See other posts from Stack Overflow or by psihodelia
Published on 2010-04-13T11:48:15Z Indexed on 2010/04/13 11:52 UTC
Read the original article Hit count: 394

Filed under:
|
|
|

I have a number of very long arrays. No run-time sort is possible. It is also time consuming to sort them manually. Moreover, new elements can be added in any order later, so I would like to sort them by value using C preprocessor or maybe there is any compilers flag (GCC)?

For example:

sometype S[] = {
  {somevals, "BOB", someothervals},
  {somevals, "ALICE", someothervals},
  {somevals, "TIM", someothervals},
}

must be sorted so:

sometype S[] = {
   {somevals, "ALICE", someothervals},
   {somevals, "BOB", someothervals},
   {somevals, "TIM", someothervals},
}

© Stack Overflow or respective owner

Related posts about c

    Related posts about sorting