Note that there are some explanatory texts on larger screens.

plurals
  1. POsort() doesn't work correctly in mozilla & opera
    primarykey
    data
    text
    <p>i need to sort one array but it works correctly only in Chrome. in the mozilla specification i found this text but nevertheless can't fix this: </p> <blockquote> <p>"The elements of this array are sorted. The sort is not necessarily stable (that is, elements that compare equal do not necessarily remain in their original order). If comparefn is not undefined, it should be a function that accepts two arguments x and y and returns a negative value if x &lt; y, zero if x = y, or a positive value if x > y."</p> </blockquote> <p>and this link <a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort" rel="nofollow">https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/sort</a> may be it will help you and me</p> <p>this is my code</p> <pre><code>arr.sort(sortTrip); function sortTrip(a, b) { if (a.to != b.from) return 1; if (a.to == b.from) return -1; } </code></pre> <p>And this is the <code>arr</code>:</p> <pre><code>var arr = [ { "from": "Moscow", "to": "Rome", "transport": "NSB Regiontog Train", "seat": "25" }, { "from": "Oslo", "to": "Paris", "transport": "NSB Regiontog Train", "seat": "25" }, { "from": "Helsinki", "to": "Tokio", "transport": "NSB Regiontog Train", "seat": "25" }, { "from": "Tokio", "to": "Moscow", "transport": "NSB Regiontog Train", "seat": "25" }, { "from": "Paris", "to": "New-York", "transport": "NSB Regiontog Train", "seat": "25" }, { "from": "Rome", "to": "Oslo", "transport": "NSB Regiontog Train", "seat": "25" } ] </code></pre> <p>result must be </p> <ul> <li>Helsinki - Tokio</li> <li>Tokio - Moscow</li> <li>Moscow - Rome</li> <li>Rome - Oslo</li> <li>Oslo - Paris</li> <li>Paris - New-York</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload