I have a list as follows:
<ul>
  <li>First</li>
  <li>Second</li>
  <li>Third</li>
  <li>Fourth</li>
  <li>Fifth</li>
</ul>
What I want is to order the list based on different conditions. For example if the variable state == "foo", I want the Fourth li to appear first and the Second li to appear last like so:
<ul>
  <li>Fourth</li>
  <li>First</li>
  <li>Third</li>
  <li>Fifth</li>
  <li>Second</li>
</ul>
And if the state == "bar" I want the list to appear in some other way.
Also consider that there may be future conditions where state may be equal to "baz" or "foobar" each having their own order. So writing custom conditionals for each state is not an option.
My idea was to maintain an ordered array for each state and then render the list according to the array using something like Mustache or Handlebars. Is there any better solution to this which is also future proof?