Template:CharacterList

Explanation
The first part of the code defines a variable char which is an ordered list of a-f corresponding to the characters in order from Lann to Vella based on whether or not the name of the corresponding character is present in. This is done by looking for each character in order and adding their letter to the string if they are in the input.

So if we recieved "Vella Evie Fiona" we would check for Lann, no lann so we skip 'a', check for Fiona, we have a Fiona so add a 'b', check for Evie, we have an Evie so we add a 'c', etc. until char would equal "bcf". b for Fiona, c for Evie, and f for Vella.

The second part is a series of switches that basically goes through char one letter at a time, turning the ordered letters into a comma separated list.

So with our example "Vella Evie Fiona" which turned into "bcf" we find 'b' first and add "Fiona" to the beginning of the list. The string is longer than 1 so it adds ", " and keeps going where it finds a 'c' which means it adds "Evie". The string is longer than 2 so it adds ", " and continues to the 'f' which adds "Vella". The string is not longer than 3 so it stops. We end up with "Fiona, Evie, Vella."

There are a couple special cases in the second half. If char has 0 length the result is immediately "" rather than going through the list. If char is 6 letters long all the characters are in the list. There is only one combination of all things within a set, so it just uses a predefined list.

Adding a new character: {{#switch:{{#sub:{{#var:char}}|(number of characters-1)|1}}
 * In this first half copy the }} code and insert it with the proper values. The order of these statements is what determines the order of the letters, and hence the resulting list.
 * In the second part increment the first case of the switch (currently "6=" so it would become "7=") and add the new character to the predefined list.
 * Add the new character and it's letter to each of the switch statements that switch on {{#ifexpr:{{#len:{{#var:char}}}}>(number of characters-1)|,
 * (Second to last letter)=(second to last char)
 * (last letter)=(last char)}}

Usage
Given a list of characters, this templates orders them properly and formats them as links.

Example
produces

produces

produces

produces

produces

produces

produces

produces