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
187 stars 19 forks source link

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

Closed rbyh closed 3 months ago

rbyh commented 6 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 6 months ago

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

rbyh commented 6 months 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 6 months 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 6 months ago

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

johnjosephhorton commented 3 months ago

New version does sort this way - can you update docs, @rbyh ?