add `reverse` prim (for both lists and strings)

tests for this already exist in the language tests.  it's also used in
some tests whose main purpose is to test other things, so it's good to
have.
fix bug where `sort` mutated input agentset