D
D
dimitriy162014-03-14 15:17:28
HTML
dimitriy16, 2014-03-14 15:17:28

How to sort a list in a dropdown select?

There is a database table with cities in alphabetical order.
In the drop-down menu of the select type, you need to load a list of cities from the database, but display certain 5-6 cities (the largest in terms of population) first, and the rest of the cities in alphabetical order. For example:

Киев
Днепропетровск
Харьков 
Авдеевка 
Артёмовск 
Волноваха 
Горловка 
Дебальцево 
....

Is it necessary to add a "weight" or "rank" column to the table for such sorting?
Poke, please, with your nose into the decision of a novice programmer.
Written in Ruby on Rails

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
max_mara, 2014-03-14
@max_mara

Well, at least you should have a `population` field for each city, and sort by it. Or you can add ranks. Ruby itself or the DB have no idea which cities are the largest in terms of population

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question