Select to view content in your preferred language

Alphabetizing responses to a repeat question

08-07-2023 08:27 AM
New Contributor II

Hi all, 

I have a survey where users identify all the plant species in an area. Users select a species in the repeat and some additional information, then repeat for each species they see. There is a need for the surveyor to see the list of species they have observed, which can get quite long. I have created a HTML table that lists all the species observed and their associated data as a note in the repeat below. 





This works well, but can make going back and finding if you entered a species already difficult if you have 100+ entries. Is there a way to alphabetize such a list by species? Open to different list building methodologies as well.

0 Kudos
2 Replies
MVP Esteemed Contributor

No there is no built it way.  You would have to write a custom javascript function.  join just uses them as they were created.

In my form I use a seperate summary page at the end of the form and the grid appearance.  That way it is on its own page and has more room horizontally and vertically.  I have my species list setup up like

CODE   Scientific Name  Common Name

that way the user can search on anything they may know.


hope that helps


New Contributor III

We have a similar issue that 'messes' up dashboards when the answers are selected in different orders.

As mentioned, no inbuilt sort() function and can make your own.

 * JavaScript functions for Survey123

function sort_many(selected) {

    // Add your code here

    var selected_array = selected.toString().split(",")
    var selected_sorted = selected_array.sort();
    return selected_sorted.toString()


Then in the survey can use a pulldata("@javascript", ...

PS Javascript will only run if the a user is logged in.