I need to run both sort! and uniq! on an array. Which is better to run first? Or is there a way to combine these into one command?
I need to run both sort! and uniq! on an array. Which is better
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I made a little benchmark test with different combinations of uniq uniq! sort and sort!
There are no significant differences:
What you may not use is something like:
uniq! will result in nil and sort! will throw an exception.
The benchmark I used: