expectedparrot / edsl

Design, conduct and analyze results of AI-powered surveys and experiments. Simulate social science and market research with large numbers of AI agents and LLMs.
https://docs.expectedparrot.com
MIT License
97 stars 14 forks source link

Results `sort_by()` method does not behave as expected #459

Open rbyh opened 2 months ago

rbyh commented 2 months ago

I expect it to sort fields in the order that I have applied it, but it does it in reverse:

image
johnjosephhorton commented 1 month ago

Can you say a bit more here - what's the expected behavior?

rbyh commented 1 month ago

If I sort by column A, and then by column B, I expect column A to remain the first sorted thing (like SQL). But it does the reverse -- it makes column B the first sorted thing.

johnjosephhorton commented 1 month ago

I see. This might be challenging because it would require the dataset to have a "memory" of what is sorted by and I'd prefer to keep it stateless. What about is sorted could take multiple keys, like this:

results.sort_by('a', 'b')

which would sort by a, then b.

rbyh commented 1 month ago

Yes, I would prefer sort_by('a', 'b') but I thought we discussed a reason to not do it that way?