String in alphabetical order Ruby -


i new ruby. have written solution in java

public boolean checkorder(string input) {         boolean x = false;         (int = 0; < input.length() - 1; i++) {             if (input.charat(i) < input.charat(i + 1) || input.charat(i) == input.charat(i + 1)) {                 x = true;             } else {                 return false;             }         }         return x;      } 

i want same in ruby how can convert same ruby. thanks.

def checkorder(input)   input.chars.sort == input.chars.to_a end 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

ruby - Nesting modules inside of a Rails eninge gem -

Eclipse formatter for java ending braces -