|
| ||||||||||
See also: is_sorted
_subject to be a vector.
Elements are sorted according to predicate (a method that returns true or false).
_subject is modified and returned with elements in the sorted order.
predicate is optional. It is a method that compares _subject and its first argument
returning true if _subject should be before the first argument in the sorted order.
The default value is object_less, also called ascending
which sorts all numbers first in ascending order, then
all other objects in alphabetical order when they are printed using to_html.
<vector "aab" 347 "aaa" 346/>.<sort/>
![]() | <vector 346 347 "aaa" "aab"/> |
<method order_by_x obj=req> obj.x.<more_or_equal .x/> </> <vector <thing x=100/> <thing x=20/> <thing x=10/> />. <sort order_by_x />
![]() | <vector <thing x=10/> <thing x=20/> <thing x=100/>/> |
<vector <thing a="f" x=0/> <thing a="f" x=1/>
<thing a="g" x=1/> <thing a="g" x=0/>
<thing a="g" x=3/> <thing a="g" x=2/>
/>.
<sort
<method sort_by_a_then_x obj=req>
<if> .a.<equal obj.a/>
.x.<object_less obj.x/> <!-- sort by 2nd key -->
else
.a.<object_less obj.a/> <!-- sort by primary key -->
</if>
</method>
/>![]() | <vector <thing x=0 a="f"/> <thing x=1 a="f"/> <thing x=0 a="g"/> <thing x=1 a="g"/> <thing x=2 a="g"/> <thing x=3 a="g"/>/> |
© Copyright 2007 Clear Methods, Inc.