• 1
    Input and Output Data
    • Tasks
  • 2
    Conditions
    • Tasks
  • 3
    For Loop
    • Tasks
  • 4
    Strings
    • Tasks
  • 5
    While Loop
    • Tasks
  • 6
    Lists
    • Tasks
  • 7
    Two-Dimensional Arrays
    • Tasks
  • 8
    Dictionaries
    • Tasks
  • 9
    Sets
    • Tasks
  • 10
    Functions and Recursion
    • Tasks
  • к

Занятие 10. Functions and recursion

Difficulty level:

Task«Summer of all elements of the matrix»

You work in an online store and you need to create a system for sorting goods according to various criteria. Each product has a name, price and rating. It is necessary to realize a higher order function that creates specialized sorters for a list of goods.
rn
The function should take the design criterion (name, price or rating) and direction (by increasing or decreasing), and return the function-sorter that sorts the list of goods according to the specified parameters.

Input format

The first line contains the amount of goods n.

the last line contains a criterion of sorting and a direction: criterion: name/price/rating, direction: ASC/DesC)

Output format

sorted list of goods, each product on a separate line in format: name the price rating

Example

Input

4
Laptop 50000 4.5
Mouse 1500 4.2
Keyboard 3000 4.8
Monitor 25000 4.1
Price asc

Output

mouse 1500 4.2
Keyboard 3000 4.8
Monitor 25000 4.1
Laptop 50000 4.5

Hint

There will be no clue here, decide for yourself!

main.py
Test 1
Test 2
Test 3
Test 4
Test 5
Test 6
Test 7
Test 8
Test 9
Test 10
Developer’s solution

🎉 Congratulations! 🎉

You did an excellent job with the task! It was a challenging problem, but you found the correct solution. You are one step closer to mastering programming! Keep up the good work, because every stage you pass makes you even stronger.

AD

Advertisement

red-snake blue-snake green-snake

Running your code...

Помощник ИИ

Привет! Я твой помощник по программированию. Задавай любые вопросы по Python, я могу рассказать о функциях, методах, обьяснить то, что тебе не понятно, а так же о текущей задаче!