Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. List of JavaScript Objects and Functions
Forum Update on Monday, May 27th 2025

List of JavaScript Objects and Functions

Scheduled Pinned Locked Moved Solved QML and Qt Quick
5 Posts 2 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Diarby
    wrote on 17 Feb 2018, 18:42 last edited by
    #1

    Hi everyone,
    I need to sort a JS array of objects like this { productId : "", product : "", price : 0, rebate : "", description: "" }
    This is my code :
    source.sort(function(a,b){
    return a.product.toLocaleLowerCase().localCompare(b.product.toLocaleLowerCase())
    });
    When running, I got this error :
    Starting /home/diarby/studio/qt/projects/build-test-Desktop_Qt_5_10_0_GCC_64bit-Debug/qtc_Desktop_Qt_5_10_0_GCC_64bit_Debug/install-root/test...
    qrc:/datasource.js:1277: TypeError: Property 'localCompare' of object orange is not a function

    Here, orange is the value of product property. and source is the array.
    In the manual, it is said that ECMA-262 is supported and localCompare() is really a function.

    How can I do array sorting on basis of string objects ?

    J 1 Reply Last reply 18 Feb 2018, 13:15
    0
    • D Diarby
      17 Feb 2018, 18:42

      Hi everyone,
      I need to sort a JS array of objects like this { productId : "", product : "", price : 0, rebate : "", description: "" }
      This is my code :
      source.sort(function(a,b){
      return a.product.toLocaleLowerCase().localCompare(b.product.toLocaleLowerCase())
      });
      When running, I got this error :
      Starting /home/diarby/studio/qt/projects/build-test-Desktop_Qt_5_10_0_GCC_64bit-Debug/qtc_Desktop_Qt_5_10_0_GCC_64bit_Debug/install-root/test...
      qrc:/datasource.js:1277: TypeError: Property 'localCompare' of object orange is not a function

      Here, orange is the value of product property. and source is the array.
      In the manual, it is said that ECMA-262 is supported and localCompare() is really a function.

      How can I do array sorting on basis of string objects ?

      J Offline
      J Offline
      JKSH
      Moderators
      wrote on 18 Feb 2018, 13:15 last edited by
      #2

      @Diarby said in List of JavaScript Objects and Functions:

      qrc:/datasource.js:1277: TypeError: Property 'localCompare' of object orange is not a function

      Here, orange is the value of product property. and source is the array.
      In the manual, it is said that ECMA-262 is supported and localCompare() is really a function.

      Do you mean localeCompare()?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      2
      • D Offline
        D Offline
        Diarby
        wrote on 19 Feb 2018, 09:23 last edited by
        #3

        Hello, yes I do. Please see my code on top.
        I just copied and pasted "as is" the error message received from the application.

        J 1 Reply Last reply 19 Feb 2018, 09:53
        0
        • D Diarby
          19 Feb 2018, 09:23

          Hello, yes I do. Please see my code on top.
          I just copied and pasted "as is" the error message received from the application.

          J Offline
          J Offline
          JKSH
          Moderators
          wrote on 19 Feb 2018, 09:53 last edited by
          #4

          @Diarby

          1. localeCompare()
          2. localCompare()

          You need #1 but you wrote #2

          Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

          1 Reply Last reply
          2
          • D Offline
            D Offline
            Diarby
            wrote on 20 Feb 2018, 01:13 last edited by
            #5

            Oh my God ! Thanks for your help. I was really bad there.

            1 Reply Last reply
            0

            1/5

            17 Feb 2018, 18:42

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved