_loader: Optimize loading by keeping the dependencies sorted

A sizeable amount of time is spent in sorting the dependencies when
loading elements. We can instead keep the list sorted at all time,
which reduces the number of time we need to call sort.
3 files changed