user
Write a response that appropriately completes the request.

### Instruction:
Write an algorithm that sorts an array of integers

### Response:
assistant
def sort_array(arr)
  sorted = false
  
  while !sorted
    sorted = true
    
    (0...arr.length - 1).each do |i|
      if arr[i] > arr[i + 1]
        arr[i], arr[i + 1] = arr[i + 1], arr[i]
        sorted = false
      end
    end
  end
  
  arr
end