Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Sort an Array Function
00:00
5 left

Sort an Array Function

EasyPython

Problem

Write a function to sort an array.

Implement the function below to return the elements in ascending order. Do not use Python's built-in sort() or sorted() functions. The input is a list of integers, and the function should return the same list object after sorting it in place.

Function signature: def sort_array(nums):

Constraints

  • 0 <= nums.length <= 1,000
  • -10^9 <= nums[i] <= 10^9
  • Return the input list after sorting it in place
  • Do not use sort() or sorted()

Function Signature

def sort_array(nums):
Interviewer

Your question is Sort an Array Function. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.