public static String sortAndGetState(){
  if (_state.length() == 0) {
    return _state;
  }
  String[] states=_state.split("\\n");
  List<String> list=new ArrayList();
  for (int counter=0; counter < states.length; ++counter) {
    list.add(states[counter]);
  }
  Collections.sort(list);
  Iterator<String> iterator=list.iterator();
  String value="";
  while (iterator.hasNext()) {
    value+=iterator.next() + "\n";
  }
  _state="";
  return value;
}

public static String sortAndGetState ( ) { if ( _state . length ( ) == 0 ) { return _state ; } String [ ] states = _state . split ( "\\n" ) ; List < String > list = new ArrayList ( ) ; for ( int counter = 0 ; counter < states . length ; ++ counter ) { list . add ( states [ counter ] ) ; } Collections . sort ( list ) ; Iterator < String > iterator = list . iterator ( ) ; String value = "" ; while ( iterator . hasNext ( ) ) { value += iterator . next ( ) + "\n" ; } _state = "" ; return value ; }
splits state at new line character ( ' \ n ' ) , sorts the resulting array and returns joined array . array is joined using ' \ n ' as a delimiter between its members .
