Not really, you cannot sort in C at compile time (at least if you want to sort a large enough number of constant integer compile-time values, in this case having 300 macros or functions named SORT_1 , SORT_2 , ... SORT_300 impractical, unless you generate these functions or macros that you don't want), however ....
A pragmatic approach would be to use your own or some other preprocessor (e.g. gpp ) and ask it to execute. Or simply, specify the numbers in some included file and generate this sorted file (for example, using the make rule with awk and sort )
You can also consider linking with link-time-optimization by compiling with LTO libc using LTO-optimized qsort . This is no ordinary AFAIK, and you have no guarantee that the compiler is smart enough to embed your LTO qsort , etc. (AFAIK, current C compilers do not).
If you are compiling with the recent GCC (4.8, 4.9, or soon 5.0 in March 2015), you can configure it (e.g. using MELT or with your own C ++ plugin) to define your __builtin_my_compile_time_sort (or maybe some _Pragma ) to complete the task. This is specific to the compiler (it could mean a few days of work if you don't already know MELT)
The easiest way would be to take a slightly more complicated assembly step. It's not a big problem.
source share