RosettaCodeData/Task/Sort-an-array-of-composite-structures/Zkl/sort-an-array-of-composite-structures.zkl
2017-09-25 22:28:19 +02:00

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")