!--a11y-->
Ordering
Collections 
By default, the resources in a collection have an arbitrary sequence and no special order. If you want to explicitly specify an order, you can:
●
Set the ordering of
the collection to manual with the setOrderType()method offered by the ICollection interface
●
Use the methods of
IReorderList to change the sequence of the resources in the
collection
The UML diagram shows the main classes and interfaces involved in the ordering of collections.

Interface or Class |
Purpose |
IReorderList |
Offers methods to
reposition resources. |
IPositioning |
Stores the name of the resource that is to be repositioned and references the IPosition object that contains the target position. |
|
A container for the
target position of a resource. The target position is specified using the
definitions provided by ●
OrderPosition.FIRST ●
OrderPosition.LAST ●
OrderPosition.BEFORE ●
OrderPosition.AFTER |
To enable the resources in a collection to be ordered, you first set the ordering of the collection to manual:
ICollection coll = …;
coll.setOrderType(OrderType.MANUAL);
If a
collection does not support ordering, the exception NotSupportedException is thrown.
Once
ordering is set to manual, you can reposition the resources as required. The
code extract shows how a collection with the children 1st,
2nd,
3rd,
4th
(ordered in this
sequence) is reordered to 4th, 3rd, 1st, 2nd. The ReorderList.add()method repositions the resources
according to the information provided by the Positioning object that is passed to the
method as an argument. The IPositioning object contains the name
of the resource involved and its new position.

When the new position is relative, for example,
OrderPosition.BEFORE, then it is specified in
relationship to another resource. For example, the following code line
specifies that the resource 3rd must be moved behind the resource
4th :
reordering.add(new Positioning(″3rd″,
new Position(″4th″, OrderPosition.AFTER)))
IReorderList reordering = new ReorderList();
reordering.add(
new Positioning(″4th″, new Position.createFirstPosition())
);
reordering.add(
new Positioning(″1st″, new Position.createLastPosition())
);
reordering.add(
new Positioning(″2nd″, new Position(″1st″, OrderPosition.BEFORE))
);
reordering.add(
new Positioning(″3rd″, new Position(″4th″, OrderPosition.AFTER))
);
orderedCollection.reorder(reordering);