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

linux - Does gcc have any options to add version info in ELF binary file? -

javascript - Clean way to programmatically use CSS transitions from JS? -

android - send complex objects as post php java -