List sortKey := method( schwart := call activated SchwartzianList clone if(call argCount == 1, body := call argAt(0) foreach(value, schwart addPair(value doMessage(body, call sender), value) ) , valueName := call argAt(0) name foreach(value, call sender setSlot(valueName, value) schwart addPair(call evalArgAt(1), value) ) ) schwart ) do( SchwartzianList := Object clone do( newSlot("pairs") init := method( pairs = list ) SchwartzianPair := Object clone do( newSlot("key") newSlot("value") asSimpleString := method( "(" .. key asSimpleString .. ": " .. value asSimpleString .. ")" ) ) addPair := method(key, value, pairs append(SchwartzianPair clone setKey(key) setValue(value)) ) sort := method( if(call argCount == 0, pairs sortBy(block(x, y, x key < y key)) , if(call argCount == 1, opName := call argAt(0) name args := list(nil) pairs sortBy( block(x, y, x performWithArgList(opName, args atPut(0, y)) ) ) , sortCall := call xName := sortCall argAt(0) name yName := sortCall argAt(1) name pairs sortBy( block(x, y, sortCall sender setSlot(xName, x) sortCall sender setSlot(yName, y) sortCall evalArgAt(2) ) ) ) ) mapInPlace(p, p value) ) ) )