Sort (Rearrange) Objects in Module

This very simple script with sort the obejcts in the current module in ascending order of the specified attribute. This does not sort the view, it actually moves the objects into order.

It will also print any duplicates found, i.e. objects that have the same value for the selected attribute.

// Sort Objects in Module

 Tony Goodman

string ATTR = "Absolute Number"
Skip objects = createString

Module m = current Module

Object o = null
Object p = null

p = current Object

for o in m do
 if (o.ATTR "" == "") continue
 if (!find(objects, o.ATTR ""))
  put(objects, o.ATTR "", o)
  print("duplicate: " identifier(o) "\n")

for o in objects do
 if (o == last(m)) continue
 move(o, last(m))