Sort the results in the user autocomplete better.

Review Request #5394 — Created Feb. 3, 2014 and submitted


Review Board


Sort the results in the user autocomplete better.

The results in the user autocomplete are basically in the order that they come
from the database. This is kind of crummy when there are multiple matches.

This change adds a sort comparison mechanism which will sort all username
matches ahead of real name matches. Within those categories, the names are
sorted in alphabetical order.

Added a bunch of users with usernames that started with a common substring, and
a bunch of users with first and last names that started with the same
substring. Saw that when I put that substring in the "People" field, the
autocomplete results put all the username matches first, and all the realname
matches after.

  1. Why sort on the JavaScript side and not the API side? Just to keep the payload from changing, or are there other reasons?

    1. I can't think of a way to implement this sorting algorithm in queryset.

    2. I was thinking of just post-processing, but then that makes things painful with pagination and stuff.. Nevermind.

  1. Ship It!

Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to master (3670907).