Let's say you have a collection of objects that are part of a class:
[A, B, C, D]
But the order they are in means something. There are a finite number of orderings that you want to be able to delegate at runtime. For example [C, A, B, D], [B, D, A, C], etc. How would you go about encapsulating the notion of order in such a way that allows you to change the ordering at runtime, and add new orderings later on without changing existing code?
The language doesn't matter, but an explanation in Java or C++ is preferred.