How to optimize 'string.split("&").sort.join("&")' using Ruby on Rails? -


i using ruby on rails 3 , in code have this:

string = "surname=testsurname&name=testname" string.split("&").sort.join("&")  # 'string' value "name=testname&surname=testsurname" 

there better way that?

if better mean faster, not. that's straightforward implementation of you're intending do. how calling method? context being called in? optimize @ ways avoid performing operation more times strictly required.


Comments