Ordered Lists

While any list can be ordered by using a property of the objects it contains, it is sometimes necessary to specify an order. Ordered lists are composed of the following elements:

  • An ordered property list type.
  • An ordering property collection type which is composed of:
    • An ordering instance.
    • A value instance.

Ordered Property List Type

To begin, an Ordered Property List Type is created within the schema. It contains an additional property used to indicate what type of Ordering Property Collection Type the list should contain.

This extra property will allow applications to dynamically analyze the list and know what type of objects should be created to store the ordering information.

This type should have no property instance and no deduction rules defined.

Ordering Property Collection Type

The Ordering Property Collection Type acts as an intermediary between the list and it's ordered content. It behaves as a standard property collection, but it contains two additional properties in it's type defintion :

  • An ordering instance.
  • A value instance.
Those are links to the property instance held within the Ordering Property Collection Type that are used to store both the value within the list and the ordering information.

The value instance can be of any property collection type.

The ordering must be of a type that can be compared. Therefore, basic types such as Strings, Integers and Calendars are normally used.

While the Ordering Property Collection Type can contain more than those two instances, it is not recommended to do so as most user interface implementation will hide the Ordering Property Collection Type from the view when browsing a list, making those extra properties hidden from the end user.

Deduction rules can be used to automatically set the ordering instance based on a property held within the value instance. This can be used to order a list of collections by name for instance.

Steps to create an ordered list.

Here is a sample guide to create an ordered list. In this example, we will assume we have an type named "shelf" and a type named "book". We want to add an ordered list of "book" to the "shelf".

  1. Create a new Ordering Property Collection Type in the schema of your application and name it "ordered book".
  2. In "ordered book", create a property instance of type "book" named "current book".
  3. In "ordered book", create a property instance of type "integer" named "index".
  4. Set the value instance of "ordered book" to be "current book".
  5. Set the ordering instance of "ordered book" to be "index".
  6. Create a new Ordered Property List Type in the schema of your application and name it "ordered book list type".
  7. Set the ordering type of "ordered book list" to be "ordered book".
  8. Onthe "shelf" type definition, create a new property collection list instance and of type "ordered book list type" name it "ordered book list".
  9. Set the list fixed instance of "ordered book list" to be of type "ordered book", the reference flag should be set to "false" and the name set to "ordered book".
At this point, any object of type shelf should now contain an ordered list of book object. Any change to the "index" of an "ordered book" should be reflected in the display.