Sorting contacts in alphabetical order in React-NativeHow do you debug React Native?Hide keyboard in react-nativeHow to do logging in React Native?What is the difference between using constructor vs getInitialState in React / React Native?React Native android build failed. SDK location not found100% width in React Native FlexboxDisabling buttons on react nativeHow to add icons to React Native appWhat is the difference between React Native and React?Error Running React Native App From Terminal (iOS)

Meaning of "legitimate" in Carl Jung's quote "Neurosis is always a substitute for legitimate suffering."

Will consteval functions allow template parameters dependent on function arguments?

Polynomial division: Is this trick obvious?

How to describe a building set which is like LEGO without using the "LEGO" word?

How to continually let my readers know what time it is in my story, in an organic way?

What color to choose as "danger" if the main color of my app is red

What metal is most suitable for a ladder submerged in an underground water tank?

Slice a list based on an index and items behind it in python

How to rename multiple files in a directory at the same time

Testing if os.path.exists with ArcPy?

Understanding Python syntax in lists vs series

Does the wearer know what items are in which patch in the Robe of Useful items?

Holding rent money for my friend which amounts to over $10k?

Why when I add jam to my tea it stops producing thin "membrane" on top?

Will the volt, ampere, ohm or other electrical units change on May 20th, 2019?

How will the lack of ground stations affect navigation?

Formal Definition of Dot Product

Does addError() work outside of triggers?

How to redirect stdout to a file, and stdout+stderr to another one?

Is the seat-belt sign activation when a pilot goes to the lavatory standard procedure?

Was the dragon prowess intentionally downplayed in S08E04?

UUID type for NEWID()

Capital gains on stocks sold to take initial investment off the table

Getting a similar picture (colours) on Manual Mode while using similar Auto Mode settings (T6 and 40D)



Sorting contacts in alphabetical order in React-Native


How do you debug React Native?Hide keyboard in react-nativeHow to do logging in React Native?What is the difference between using constructor vs getInitialState in React / React Native?React Native android build failed. SDK location not found100% width in React Native FlexboxDisabling buttons on react nativeHow to add icons to React Native appWhat is the difference between React Native and React?Error Running React Native App From Terminal (iOS)






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















Currently I'm working on a mobile app. I need to pull contacts from my phone into the app I'm creating (I use expo contacts). For some reason, instead of contacts being sorted in the alphabetical order, they show up in the random order.



I'm not quite sure how to sort the contacts to display them in the alphabetical order.



Can anyone please take a look and let me know what I'm doing wrong/what I should add?



The code that I use:



// load contacts from phone

_loadContacts = async () => {
try {
await Permissions.askAsync(Permissions.CONTACTS);
const data: contacts = await Contacts.getContactsAsync( fields: [Contacts.Fields.PhoneNumbers] )


// for rendering contacts

_renderContact = ( item: firstName, lastName, name, phoneNumbers ) => (
<View style=styles.contact>
<Text style=styles.contactName>name </Text>
<Text style=styles.phoneNumbers>📞 phoneNumbers ? phoneNumbers.map(entry => entry.number).join(", ") : "undefined"</Text>
</View>
)









share|improve this question

















  • 1





    What is the structure of contacts data ??

    – pritesh
    Mar 23 at 15:41

















1















Currently I'm working on a mobile app. I need to pull contacts from my phone into the app I'm creating (I use expo contacts). For some reason, instead of contacts being sorted in the alphabetical order, they show up in the random order.



I'm not quite sure how to sort the contacts to display them in the alphabetical order.



Can anyone please take a look and let me know what I'm doing wrong/what I should add?



The code that I use:



// load contacts from phone

_loadContacts = async () => {
try {
await Permissions.askAsync(Permissions.CONTACTS);
const data: contacts = await Contacts.getContactsAsync( fields: [Contacts.Fields.PhoneNumbers] )


// for rendering contacts

_renderContact = ( item: firstName, lastName, name, phoneNumbers ) => (
<View style=styles.contact>
<Text style=styles.contactName>name </Text>
<Text style=styles.phoneNumbers>📞 phoneNumbers ? phoneNumbers.map(entry => entry.number).join(", ") : "undefined"</Text>
</View>
)









share|improve this question

















  • 1





    What is the structure of contacts data ??

    – pritesh
    Mar 23 at 15:41













1












1








1








Currently I'm working on a mobile app. I need to pull contacts from my phone into the app I'm creating (I use expo contacts). For some reason, instead of contacts being sorted in the alphabetical order, they show up in the random order.



I'm not quite sure how to sort the contacts to display them in the alphabetical order.



Can anyone please take a look and let me know what I'm doing wrong/what I should add?



The code that I use:



// load contacts from phone

_loadContacts = async () => {
try {
await Permissions.askAsync(Permissions.CONTACTS);
const data: contacts = await Contacts.getContactsAsync( fields: [Contacts.Fields.PhoneNumbers] )


// for rendering contacts

_renderContact = ( item: firstName, lastName, name, phoneNumbers ) => (
<View style=styles.contact>
<Text style=styles.contactName>name </Text>
<Text style=styles.phoneNumbers>📞 phoneNumbers ? phoneNumbers.map(entry => entry.number).join(", ") : "undefined"</Text>
</View>
)









share|improve this question














Currently I'm working on a mobile app. I need to pull contacts from my phone into the app I'm creating (I use expo contacts). For some reason, instead of contacts being sorted in the alphabetical order, they show up in the random order.



I'm not quite sure how to sort the contacts to display them in the alphabetical order.



Can anyone please take a look and let me know what I'm doing wrong/what I should add?



The code that I use:



// load contacts from phone

_loadContacts = async () => {
try {
await Permissions.askAsync(Permissions.CONTACTS);
const data: contacts = await Contacts.getContactsAsync( fields: [Contacts.Fields.PhoneNumbers] )


// for rendering contacts

_renderContact = ( item: firstName, lastName, name, phoneNumbers ) => (
<View style=styles.contact>
<Text style=styles.contactName>name </Text>
<Text style=styles.phoneNumbers>📞 phoneNumbers ? phoneNumbers.map(entry => entry.number).join(", ") : "undefined"</Text>
</View>
)






react-native






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 23 at 15:17









andriyanayandriyanay

61




61







  • 1





    What is the structure of contacts data ??

    – pritesh
    Mar 23 at 15:41












  • 1





    What is the structure of contacts data ??

    – pritesh
    Mar 23 at 15:41







1




1





What is the structure of contacts data ??

– pritesh
Mar 23 at 15:41





What is the structure of contacts data ??

– pritesh
Mar 23 at 15:41












1 Answer
1






active

oldest

votes


















1














It is possible to sort contacts using Expo. It was added in August 2018. https://expo.canny.io/feature-requests/p/sorting-options-for-contacts



If you check the documentation you can see that getContactsAsync takes a ContactQuery.



ContactQuery (see here) takes a SortType (see here), allowing you to sort the contacts by either FirstName or LastName.



A simple example would be the following.



 const data: contacts = await Contacts.getContactsAsync( 
fields: [Contacts.Fields.PhoneNumbers],
sort: Contacts.SortTypes.FirstName
);


It is worth noting that at the current time, SortType is only available for Android. So for iOS you would need to sort them in the order you want, yourself.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315218%2fsorting-contacts-in-alphabetical-order-in-react-native%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    It is possible to sort contacts using Expo. It was added in August 2018. https://expo.canny.io/feature-requests/p/sorting-options-for-contacts



    If you check the documentation you can see that getContactsAsync takes a ContactQuery.



    ContactQuery (see here) takes a SortType (see here), allowing you to sort the contacts by either FirstName or LastName.



    A simple example would be the following.



     const data: contacts = await Contacts.getContactsAsync( 
    fields: [Contacts.Fields.PhoneNumbers],
    sort: Contacts.SortTypes.FirstName
    );


    It is worth noting that at the current time, SortType is only available for Android. So for iOS you would need to sort them in the order you want, yourself.






    share|improve this answer



























      1














      It is possible to sort contacts using Expo. It was added in August 2018. https://expo.canny.io/feature-requests/p/sorting-options-for-contacts



      If you check the documentation you can see that getContactsAsync takes a ContactQuery.



      ContactQuery (see here) takes a SortType (see here), allowing you to sort the contacts by either FirstName or LastName.



      A simple example would be the following.



       const data: contacts = await Contacts.getContactsAsync( 
      fields: [Contacts.Fields.PhoneNumbers],
      sort: Contacts.SortTypes.FirstName
      );


      It is worth noting that at the current time, SortType is only available for Android. So for iOS you would need to sort them in the order you want, yourself.






      share|improve this answer

























        1












        1








        1







        It is possible to sort contacts using Expo. It was added in August 2018. https://expo.canny.io/feature-requests/p/sorting-options-for-contacts



        If you check the documentation you can see that getContactsAsync takes a ContactQuery.



        ContactQuery (see here) takes a SortType (see here), allowing you to sort the contacts by either FirstName or LastName.



        A simple example would be the following.



         const data: contacts = await Contacts.getContactsAsync( 
        fields: [Contacts.Fields.PhoneNumbers],
        sort: Contacts.SortTypes.FirstName
        );


        It is worth noting that at the current time, SortType is only available for Android. So for iOS you would need to sort them in the order you want, yourself.






        share|improve this answer













        It is possible to sort contacts using Expo. It was added in August 2018. https://expo.canny.io/feature-requests/p/sorting-options-for-contacts



        If you check the documentation you can see that getContactsAsync takes a ContactQuery.



        ContactQuery (see here) takes a SortType (see here), allowing you to sort the contacts by either FirstName or LastName.



        A simple example would be the following.



         const data: contacts = await Contacts.getContactsAsync( 
        fields: [Contacts.Fields.PhoneNumbers],
        sort: Contacts.SortTypes.FirstName
        );


        It is worth noting that at the current time, SortType is only available for Android. So for iOS you would need to sort them in the order you want, yourself.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 23 at 16:48









        AndrewAndrew

        7,22241730




        7,22241730





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315218%2fsorting-contacts-in-alphabetical-order-in-react-native%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript