I think that a priority queue is what you're looking for. Here there are several implementation, also for c and with a little of modifications you can use for your purpose.
This data structure allow only two operation
- insert an element
- extract that one with highest priority
In your case the priority is higher, the lower the job.