WatermelonDB icon indicating copy to clipboard operation
WatermelonDB copied to clipboard

Inconsistent ordering when using LokiJSAdapter

Open tiagocpeixoto opened this issue 9 months ago • 1 comments

When using LokiJSAdapter in my project's tests, Q.sortBy is supposedly not working correctly.

For example, I have an entity that has an "order" property:

// Entity 1: { id: "foo", order: "0"}

// Entity 2: { id: "bar", order: "1"}

When I set Q.sortBy("order", Q.asc), Entity 1 comes first. At this moment everything is fine!

If I define the following:

// Entity 1: { id: "foo", order: "0V"} <-- different order value

// Entity 2: { id: "bar", order: "1"}

In this case, the same statement - Q.sortBy("order", Q.asc) - returns Entity 2 as the first element.

But in javascript, "0V" < "1".

Am I doing something wrong or is there an inconsistency?

tiagocpeixoto avatar Sep 23 '23 20:09 tiagocpeixoto

Facing same issue.

suman379 avatar Nov 21 '23 06:11 suman379