Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: stabilize Array.sort #762

Merged
merged 1 commit into from
Jul 5, 2019
Merged

fix: stabilize Array.sort #762

merged 1 commit into from
Jul 5, 2019

Conversation

DanielRuf
Copy link
Contributor

@DanielRuf DanielRuf commented Jun 25, 2019

This PR stabilizes the sorting as it was instable before NodeJS 11 (V8 v7.0) and in NodeJS it was stabilized as the sorting algorithm was changed to TimSort with a pre-peocessing and a post-processing phase.

References:
nodejs/node#24294
https://v8.dev/blog/array-sort

Probably we should change the added logic to order by name because America/Caracas and America/Santo_Domingo have the same abbrScore, offsetScore and zone.population but C comes before S in the alphabet and so it should be probably first (many breaking tests due to stable sorting now).

ZoneScore {
    zone: {
      name: 'America/Caracas',
      abbrs: [Array],
      untils: [Array],
      offsets: [Array],
      population: 2900000
    },
    offsetScore: 0,
    abbrScore: 9
  },
  ZoneScore {
    zone: {
      name: 'America/Santo_Domingo',
      abbrs: [Array],
      untils: [Array],
      offsets: [Array],
      population: 2900000
    },
    offsetScore: 0,
    abbrScore: 9
  },

@jsf-clabot
Copy link

jsf-clabot commented Jun 25, 2019

CLA assistant check
All committers have signed the CLA.

@DanielRuf DanielRuf changed the title fix: stabilize support fix: stabilize Array.sort Jun 25, 2019
@ellenaua ellenaua merged commit 0ff4006 into moment:develop Jul 5, 2019
@DanielRuf DanielRuf deleted the fix/stabilize-array-sort branch July 6, 2019 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants