Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 75: Add support for sorting Methods by priority #96

Merged

Conversation

fohrloop
Copy link
Owner

@fohrloop fohrloop commented Dec 9, 2023

Add: get_prioritized_methods

Take an unordered list of Methods and sort them by priority using the priority_order and automatic ordering. The priority_order is used to define groups of priority (sets of methods). The automatic ordering part is used to order the methods within each priority group. In particular, all methods supported by the current platform are placed first, and all supported methods are then ordered alphabetically (ignoring case).

Example

Assuming: Current platform is Linux.

  >>> methods = [LinuxA, LinuxB, LinuxC, MultiPlatformA, WindowsA]
  >>> get_prioritized_methods(
  >>>    methods,
  >>>    priority_order=[{"WinA", "LinuxB"}, "*"],
  >>> )
  [LinuxB, WindowsA, LinuxA, LinuxC, MultiPlatformA]

Explanation:

WindowsA and LinuxB were given high priority, but since the current platform is Linux, LinuxB was prioritized to be before WindowsA.

The asterisk ('*') is converted to a set of rest of the methods: {"LinuxA", "LinuxC", "MultiPlatformA"}, and those are then
automatically ordered. As all of them support Linux, the result is just the methods sorted alphabetically. The asterisk in the end is optional; it is added to the end of priority_order if missing.

* sort_methods_by_priority which sorts set of methods (WIP)
* get_prioritized_methods which takes an unordered list of methods and
 priority_order and returns a sorted list of methods
@fohrloop fohrloop changed the title Issue 75 replace modecurationopts with priority order pt6 Issue 75: Add get_prioritized_methods Dec 9, 2023
@fohrloop fohrloop changed the title Issue 75: Add get_prioritized_methods Issue 75: Add support for sorting Methods by priority Dec 9, 2023
@fohrloop fohrloop merged commit dcbc8e1 into main Dec 9, 2023
@fohrloop fohrloop deleted the issue-75-replace-modecurationopts-with-priority-order-pt6 branch December 9, 2023 19:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant