WordPress Custom Search By Alphabet and order by asc and sesc

This is a bit of a broad question and I don’t have time to hash out the whole thing, but your search code needs to modify the query something very much like:

add_action(
  'pre_get_posts',
  function ($qry) {
    if ($qry->is_search()) {
      $qry->set('orderby','title');
    }
  }
);

I have a feeling a lot of details are missing from the question though.