Thoughtworks logo

What's the difference between a.sort and a.sort! ?

To sort an array a in Ruby, you could either do a.sort or a.sort! . What's the difference between the two? Discuss performance and end result. How would you use them? Provide one example where a.sort is better than a.sort! and one example where a.sort! is better than a.sort.

750
top 5
25
submissions
DONE
43 months ago
Small pic thoughtworks challenge
Deliverables

Submit your solution
Leaderboard
This challenge has received 24 submissions
Top 5 share 750
150 S Rochester Institute of Technology
150 Square pic 0203152114 New York University
150 Square pic profile San Francisco State University
150 J University of California at Berkeley
Contact Us!
Share your thoughts, ideas and stories with 300,000 peers Write for our Blog