Title: Sorting the list
Last modified: August 31, 2016

---

# Sorting the list

 *  Resolved [Todd Edelman](https://wordpress.org/support/users/toddedelman/)
 * (@toddedelman)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/sorting-the-list/)
 * Hi
 * Is there any way the list can be sorted based on ABC?
 * Current order is random.
 * Thanks!
 * [https://wordpress.org/plugins/listo/](https://wordpress.org/plugins/listo/)

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Takayuki Miyoshi](https://wordpress.org/support/users/takayukister/)
 * (@takayukister)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/sorting-the-list/#post-6986616)
 * No, there isn’t.
 * But if you are familiar with WordPress filters and actions, it’s easy to reorder
   the output using the `wpcf7_form_tag_data_option` filter hook in _contact-form-
   7/modules/listo.php_ file.
 *  [Daniel Doinitsin](https://wordpress.org/support/users/danielge/)
 * (@danielge)
 * [10 years, 4 months ago](https://wordpress.org/support/topic/sorting-the-list/#post-6986715)
 * Hi Takayuki Miyoshi
 * Thanks for this great plugin!
 * could you write to use more how to order as ABC ?
 * There is several theads about this. i open the file which you said and find the
   line wpcf7_form_tag_data_option and its
    `add_filter( 'wpcf7_form_tag_data_option','
   wpcf7_listo', 10, 3 );`
 * so what i have to change here to get ABC ordering ?
 * Many many thanks!
 *  [designgr82](https://wordpress.org/support/users/designgr82/)
 * (@designgr82)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/sorting-the-list/#post-8177476)
 * Hi there,
 * Any update on this? I am also looking for a solution to sort the list in alphabetical
   order.
    -  This reply was modified 9 years, 9 months ago by [designgr82](https://wordpress.org/support/users/designgr82/).
 *  [wordpressfab](https://wordpress.org/support/users/wordpressfab/)
 * (@wordpressfab)
 * [9 years, 7 months ago](https://wordpress.org/support/topic/sorting-the-list/#post-8345246)
 * In case [@designgr82](https://wordpress.org/support/users/designgr82/) or anybody
   else is still looking for a solution to this, here is the code to add to your
   function.php in order to sort the list :
 *     ```
       function wpcf7_listo_ordered( $data) {
       	sort($data);
       	return $data;
       }
       add_filter( 'wpcf7_form_tag_data_option', 'wpcf7_listo_ordered', 11, 1 );
       ```
   
 *  [marcie73](https://wordpress.org/support/users/marcie73/)
 * (@marcie73)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/sorting-the-list/#post-8668311)
 * Thnank you WordPressfab
    I tried your code above but i get this error…
 * Warning: sort() expects parameter 1 to be array, null given in /home/tdlevent/
   public_html/wp-content/themes/tdlevents/functions.php on line 15
 *  [marcie73](https://wordpress.org/support/users/marcie73/)
 * (@marcie73)
 * [9 years, 4 months ago](https://wordpress.org/support/topic/sorting-the-list/#post-8776762)
 * Hello, any help? Please… thank you!
 *  [jjoldman](https://wordpress.org/support/users/jjoldman/)
 * (@jjoldman)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/sorting-the-list/#post-9047482)
 * If anyone is still looking for an answer, my solution is to use jquery to sort
   the country list. Below is the sorting code:
 * var options = jQuery(‘select[name=country] option’); // change this to your identifier
   
   var arr = options.map(function(_, o) { return { t: jQuery(o).text(), v: o.value};}).
   get(); arr.sort(function(o1, o2) { return o1.t > o2.t ? 1 : o1.t < o2.t ? -1 :
   0; }); options.each(function(i, o) { o.value = arr[i].v; jQuery(o).text(arr[i].
   t); });
 * Hope this helps!
 *  [studioavanti](https://wordpress.org/support/users/studioavanti/)
 * (@studioavanti)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sorting-the-list/#post-9364334)
 * [@wordpressfab](https://wordpress.org/support/users/wordpressfab/) : thanks for
   your code to sort Listo in alphabetical order, it works for me.
    Just one thing:
   this sorting function is OK for ASCII characters (US), but in some other languages,
   countries beginning with non ASCII characters (É È Î Ç…) are listed at the end,
   after XYZ. So how to handle those characters in alphabetical order? I tried to
   add the PHP setlocale function to your code but have not enough skills to achieve
   this. Thanks for your help!
 *  [studioavanti](https://wordpress.org/support/users/studioavanti/)
 * (@studioavanti)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sorting-the-list/#post-9364466)
 * I finally found a way to sort the countries list including non ASCII characters(
   french in my case).
    It’s based on [@wordpressfab](https://wordpress.org/support/users/wordpressfab/)
   code and added in function.php:
 *     ```
       function wpcf7_listo_ordered( $data) {
       	setlocale(LC_ALL, 'fr_FR.utf8');
       	sort($data, SORT_LOCALE_STRING);
       	return $data;
       }
       add_filter( 'wpcf7_form_tag_data_option', 'wpcf7_listo_ordered', 11, 1 );
       ```
   
 * A **setlocale** PHP function is added with specific language to treat : **fr_FR.
   utf8** for french.
    And **SORT_LOCALE_STRING** parameter added to **sort** function
   to handle language specific characters.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Sorting the list’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/listo.svg)
 * [Listo](https://wordpress.org/plugins/listo/)
 * [Support Threads](https://wordpress.org/support/plugin/listo/)
 * [Active Topics](https://wordpress.org/support/plugin/listo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/listo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/listo/reviews/)

 * 9 replies
 * 8 participants
 * Last reply from: [studioavanti](https://wordpress.org/support/users/studioavanti/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/sorting-the-list/#post-9364466)
 * Status: resolved