0
0
NumPydata~15 mins

Why sorting matters in NumPy - See It in Action

Choose your learning style9 modes available
Why Sorting Matters
📖 Scenario: Imagine you work in a store that sells different products. You want to find out which products sell the most and which sell the least. Sorting the sales numbers helps you see this clearly.
🎯 Goal: You will create a list of sales numbers, set a threshold to find popular products, sort the sales, and then print the sorted sales to understand why sorting is useful.
📋 What You'll Learn
Create a NumPy array with exact sales numbers
Create a threshold variable to select popular products
Sort the sales array using NumPy
Print the sorted sales array
💡 Why This Matters
🌍 Real World
Sorting sales data helps businesses quickly see which products sell best and make smart decisions.
💼 Career
Data scientists and analysts often sort data to find trends and make reports easier to understand.
Progress0 / 4 steps
1
Create the sales data
Create a NumPy array called sales with these exact values: 50, 20, 75, 10, 90, 40.
NumPy
Need a hint?

Use np.array to create the array with the given numbers.

2
Set the popularity threshold
Create a variable called threshold and set it to 50 to find popular products.
NumPy
Need a hint?

Just assign the number 50 to the variable threshold.

3
Sort the sales data
Create a new variable called sorted_sales that holds the sorted version of sales using np.sort().
NumPy
Need a hint?

Use np.sort(sales) to get the sorted array.

4
Print the sorted sales
Print the variable sorted_sales to see the sales numbers in order.
NumPy
Need a hint?

Use print(sorted_sales) to show the sorted numbers.