8 lines
262 B
Text
8 lines
262 B
Text
class P{var name,value;
|
|
fcn init(nm,val){name,value=vm.arglist}
|
|
fcn __opLT(p){name<p.name} // implementation of P1 < P2
|
|
}
|
|
// create list of pairs:
|
|
p:=List(P("sam","a"),P("fred","b"),P("chris","c"));
|
|
p.sort();
|
|
p.apply("name"); //-->L("chris","fred","sam")
|