IngoMeyer441 / simple-term-menu

A Python package which creates simple interactive menus on the command line.
MIT License
492 stars 43 forks source link

Feature request: Unsorted flag for 'multi_select' return object #52

Open Cs137 opened 2 years ago

Cs137 commented 2 years ago

Dear Ingo,

first of all many thanks for this nice package, if I run into you in Seecasino you'll get at least a coffee ;-)

I'd like to use your module for selections where I want to keep track of the selection order. If I understand your code correctly, I could just remove the sorted function over here.

Since others might have a usecase for an unsorted tuple as well, I'd like to suggest adding a flag to the __init__ method of the Selection class over here. If there is an interest to implement such a functionality into your package, I could offer to care about a pull request with the mentioned suggestions.

Best regards, Christian

IngoMeyer441 commented 2 years ago

Hey Christian,

first of all many thanks for this nice package, if I run into you in Seecasino you'll get at least a coffee ;-)

Ah nice, simple-term-menu is used by other Forschungszentrum Jülich employees. :+1: :smile:

I'd like to use your module for selections where I want to keep track of the selection order. If I understand your code correctly, I could just remove the sorted function over here.

It is a bit more complicated than this: self._selected_menu_indices is a set which is an unordered data structure. However, you could replace it with a list to preserve order and remove the sorted call as you already mentioned. Additionally, some set methods have another name on lists (for example add instead of append).

Since others might have a usecase for an unsorted tuple as well, I'd like to suggest adding a flag to the init method of the Selection class over here. If there is an interest to implement such a functionality into your package, I could offer to care about a pull request with the mentioned suggestions.

Pull requests are always welcome!

Cs137 commented 2 years ago

Hi Ingo,

thanks for your answer and the provided suggestions. I'll try to modify the package accordingly and will report about the progress.