la icon indicating copy to clipboard operation
la copied to clipboard

larry.fromlist doesnt keep order

Open alpmdog opened this issue 11 years ago • 5 comments

I have noticed that when i convert larry into list and convert it back to larry using fromlist function, larry loses order if i have some custom ordering. It looks like this is due to set function in list2index. Would it be possible to introduce a keep_order optional parameter in list2index to use another function instead of set to uniqify list? Looks like something like f5 on http://www.peterbe.com/plog/uniqifiers-benchmark would do the trick.

alpmdog avatar Mar 27 '13 18:03 alpmdog

If you store larrys in hdf5 then the label order is preserved across save and loads. Can you use hdf5 in your use case?

kwgoodman avatar Mar 27 '13 22:03 kwgoodman

I am storing data as json at some point so lists work better for me. I have actually made the changes on my local copy but i would rather not diverge too much

alpmdog avatar Mar 27 '13 22:03 alpmdog

Sounds like a reasonable feature to add. So we'd add a sort_label (True by default) to fromlist and fromtuples. Plus update docstrings, manual, and add unit tests.

Are you interested in making a pull request with those changes?

kwgoodman avatar Mar 27 '13 22:03 kwgoodman

Sure, haven't made a pull request before so it will be nice to learn how to make these

alpmdog avatar Mar 28 '13 11:03 alpmdog

Take your time, I won't be able to look at it for the next couple of weeks.

kwgoodman avatar Mar 28 '13 16:03 kwgoodman