question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sorting in request's order

See original GitHub issue

Goals

I have a filtered request with several conditions in it, I want the results to be filter in the same order. Let say, I do this request :

const query = [4, 2, 3, 1].map(id => `id = ${id}`).join(' OR ');
const users = await realm.objects('Contact').filtered(query);
return users;

Expected Results

I want the results to be ordered in that particular order => Contact with id 4, Contact with id 2, Contact with id 3, Contact with id 1.

Actual Results

The results are filtered by id => Contact with id 1, Contact with id 2, Contact with id 3, Contact with id 4.

Steps to Reproduce

Simply execute the request above, the schema is below.

Code Sample

Schema :

const Contact = {
  name: 'Contact',
  primaryKey: 'id',
  properties: {
    id: 'int',
    lastname: 'string',
    firstname: 'string',
    address: 'string',
    phones: 'string',
    email: 'string',
    picture: 'string?',
    birthday: 'date?',
    birthplace: 'string?',
  }
};

Version of Realm and Tooling

  • Realm JS SDK Version: 2.2.7
  • Node or React Native: React Native 0.53.0
  • Client OS & Version: iOS and Android
  • Which debugger for React Native: None

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
PeteOyablecommented, Apr 5, 2018

Ok, I’ve been able to have the result I want with a filter function 😃 I think we can close this issue.

Thank you all.

0reactions
chelovekdrakoncommented, Feb 14, 2020

@kneth thank you 😃 This is exactly how I did it for now 😃 Works good 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to sort the order of request types in the group in JIRA ...
You can sort it manually. There is no option to sort them e.g. alphabetically.
Read more >
Using python 'requests' package to sort by date - Stack Overflow
I want to read in the most recent press releases, and am trying to sort by date. I use requests in the following...
Read more >
How to Use sorted() and sort() in Python - Real Python
In this guide, you'll learn how to sort various types of data in different data structures, customize the order, and work with two...
Read more >
Is there a way to sort the console and network, by time for ...
Here's how to restore chronological sort order for the Network tab: Right click the Waterfall column header; In the popup menu, ...
Read more >
Paging and ordering results for a RESTful request
By default, results are sorted in ascending order ( orderBy=name ). This example sorts the result list on the name property. You can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found