cc17074 2018
cc17074 2018

Reputation: 13

Firebase firestore cant query properly

as you can see, i try to list ads on my page by highest price. It didnt work. Checking it manually, and the result is weird. The price are not in order at all.

Upvotes: 0

Views: 52

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317808

Your prices appear to be string values, which means they are going to be compared lexicographically, not numerically. In a lexicographic sort, two strings are compared by looking at the unicode values of their characters from left to right, like a dictionary. If you want a numerical sort, where the values are compared simply by their number values, you should be using a number type field instead of a string. This means you'll have to update each document to use numbers instead of strings where appropriate.

See also:

I see also you have what appears to be time values that don't much look like times. Look into using timestamp type fields instead, or numbers that will sort in chronological order.

Upvotes: 1

Related Questions