Created
February 14, 2024 00:24
-
-
Save zzstoatzz/c5b1ffc8fcabbbd6318e5670b0c18db5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from enum import Enum | |
import marvin | |
class Fruit(str, Enum): | |
apple = "apple" | |
cherry = "cherry" | |
orange = "orange" | |
banana = "banana" | |
@marvin.fn | |
def rank_fruit(fruit: list[Fruit], order_by: str) -> list[Fruit]: | |
"""return the indices of the fruit in the enum according to their order""" | |
if __name__ == "__main__": | |
rank_fruit(list(Fruit), "alphabetical") | |
# [<Fruit.apple: 'apple'>, <Fruit.banana: 'banana'>, <Fruit.cherry: 'cherry'>, <Fruit.orange: 'orange'>] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment