Please note that Sahi's development and support teams do not actively monitor this. This is more a community forum. If you are a Sahi Pro user looking for commercial support, please email support @ sahipro.com with your query.

How to compare strings that are they sorted in alphabetical order??

sujatasujata Members
edited September 2013 in Sahi - Open Source
Hi,
In my application,if I search with Keyword "S",,I should get result as "Sabira" ,"Sujata","Tiya".
So now with Sahi OS I want to check that am I getting the results in alphabetically sorted order.
Please reply me ASAP.
Thanks
Sujata

Answers

  • Hi sujata,
    Please have a look at the sample script below and modify it as per your requirement:
    _navigateTo("http://jqueryui.com/autocomplete/#multiple";);
    _setValue(_textbox("tags"), "C");
    var $collection=_collect("_listItem","/.*/",_in(_list("ui-id-1")));
    var $array= new Array();
    for(var $i=0;$i<$collection.length;$i++)
    {
      _set($array[$i],_getText($collection[$i]));
      
    }
    var $newArray= new Array();
    for(var $i=0;$i<$array.length;$i++)
    {
    $newArray[$i]=$array[$i];
    }
    $newArray.sort();
    var $bool=false
    
    for(var $i=0;$i<$array.length;$i++)
    {
      if($newArray[$i]!=$array[$i]){
       $bool=true;
      }
      else
      {
        $bool=false
      }
    }
    if($bool==true)
    {
      _log("SOrted")
        
    }
    else
    {
      _log("NOt sorted");
    }
    

    Please let me know if it helps you.

    Regards.
  • Thanks for the reply
Sign In or Register to comment.