What do you mean by popularity sorting?
Database sorting doesn't really have anything to do with popularity. Database sorting works by looking at a specific column you specify, then sorting either numerically or alphabetically depending on the column type.
you could create popularity sorting by creating a popularity column and and assigning each record a numeric value, then sort by that column.
to force certain records to the top of the results list, you would need to assign the column that is being sorted by a value that causes that record to the top.
see the w3schools page for more details on sporting: