title: Selenium code to check whether the listbox values are in alphabetical order
body: <p><a href="https://i.stack.imgur.com/5yDzD.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5yDzD.jpg" alt="enter image description here"></a>My scenario is to check whether the values in the listbox is in alphabetical order.</p>
  
  <p>My code:</p>
  
  <pre><code>package checking;
  import org.openqa.selenium.By;
  import org.openqa.selenium.WebElement;
  import org.openqa.selenium.chrome.ChromeDriver;
  import org.openqa.selenium.remote.RemoteWebDriver;
  import org.openqa.selenium.support.ui.Select;
  
  public class Alpha {
  
      public static void main(String[] args) {
  
          RemoteWebDriver driver;
          //driver = new FirefoxDriver();
  
          System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe");
          driver = new ChromeDriver();
  
          driver.manage().window().maximize();
          driver.get("http://my.naukri.com/manager/createacc2.php?othersrcp=16201&amp;err=1");
  
          WebElement single = driver.findElement(By.xpath("//*[@id='ugcourse']"));
          Select dd = new Select(single);
          String str = single.getText();
          System.out.println(str);
  
          driver.quit();
      }
  
  }
  </code></pre>
  
  <p>How to check the values are in alphabetical order. Can anyone help me to solve this issue</p>
  
  <h2>output</h2>
  
  <pre><code>Select
  Not Pursuing Graduation
  B.A
  B.Arch
  BCA
  B.B.A
  B.Com
  B.Ed
  BDS
  BHM
  B.Pharma
  B.Sc
  B.Tech/B.E.
  LLB
  MBBS
  Diploma
  BVSC
  Other
  </code></pre>
  
  <p>How to check the values are in alphabetical order. Can anyone help me to solve this issue</p>