void sortList() { SinglyLinkedNode first = null; foreach (character character in characterlist) { if (first == null) { first = new SinglyLinkedNode(character, null); } else { if (character.initiative > first.character.initiative) { first = new SinglyLinkedNode(character, first); } else { first.insert(character); } } } characterlist = new List <character>(); first.getList(characterlist); InitiativeList.ItemsSource = characterlist; }
public void insert(character _char) { if (node != null) { if (_char.initiative > node.character.initiative) { SinglyLinkedNode newnode = new SinglyLinkedNode(_char, node); node = newnode; } else { node.insert(_char); } } else { node = new SinglyLinkedNode(_char, node); } }
public SinglyLinkedNode(character _char, SinglyLinkedNode _node) { character = _char; node = _node; }