Skip to content

feat(pipeline): add numeric comparison mode to sort step#306

Open
Astro-Han wants to merge 1 commit intojackwener:mainfrom
Astro-Han:worktree-fix-sort-numeric
Open

feat(pipeline): add numeric comparison mode to sort step#306
Astro-Han wants to merge 1 commit intojackwener:mainfrom
Astro-Han:worktree-fix-sort-numeric

Conversation

@Astro-Han
Copy link
Contributor

Description

Add numeric: true option to the pipeline sort step so string-encoded numbers are compared numerically instead of lexicographically.

When APIs return numeric values as strings (e.g. "quoteVolume": "1234567.89"), the sort step uses lexicographic ordering, causing "99" to rank above "1000". With numeric: true, values are converted via Number() with a Number.isFinite() guard before comparison.

- sort:
    by: quoteVolume
    order: desc
    numeric: true

Closes #304

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 🌐 New site adapter
  • 📝 Documentation
  • ♻️ Refactor
  • 🔧 CI / build / tooling

Checklist

  • I ran the checks relevant to this PR
  • I updated tests or docs if needed
  • I included output or screenshots when useful

Screenshots / Output

 PASS  src/pipeline/transform.test.ts (21 tests)

 ✓ stepSort > sorts string-encoded numbers numerically with numeric: true
 ✓ stepSort > sorts string-encoded numbers lexicographically without numeric
 ✓ stepSort > treats non-numeric values as 0 when numeric: true
 ✓ stepSort > handles "0" and negative numbers correctly with numeric: true
 ✓ stepSort > treats missing fields as 0 when numeric: true

When APIs return numeric values as strings (e.g. "1234567.89"),
sort used lexicographic ordering. Add `numeric: true` option to
convert values via Number() before comparison, with Number.isFinite
guard for non-numeric fallback to 0.
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.

[Feature]: add numeric comparison mode to pipeline sort step

1 participant