0
0
NumPydata~15 mins

np.sort() for sorting arrays in NumPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Sorting Arrays with np.sort()
📖 Scenario: You work in a small shop that tracks daily sales numbers. You want to organize the sales data from smallest to largest to see trends easily.
🎯 Goal: Learn how to use np.sort() to sort a list of daily sales numbers in ascending order.
📋 What You'll Learn
Create a NumPy array with exact daily sales numbers
Use a variable to hold the sorted array
Use np.sort() to sort the array
Print the sorted array
💡 Why This Matters
🌍 Real World
Sorting sales data helps businesses quickly understand trends and make decisions.
💼 Career
Data scientists often sort data to prepare it for analysis and visualization.
Progress0 / 4 steps
1
Create the sales data array
Create a NumPy array called sales with these exact daily sales numbers: 250, 100, 300, 150, 200.
NumPy
Need a hint?

Use np.array() and put the numbers inside a list.

2
Prepare a variable for sorted sales
Create a variable called sorted_sales and set it to None for now.
NumPy
Need a hint?

Just write sorted_sales = None to create the variable.

3
Sort the sales array using np.sort()
Use np.sort() to sort the sales array and assign the result to sorted_sales.
NumPy
Need a hint?

Call np.sort(sales) and save it in sorted_sales.

4
Print the sorted sales array
Print the sorted_sales array to see the sales numbers sorted from smallest to largest.
NumPy
Need a hint?

Use print(sorted_sales) to display the sorted array.