Your dashboard puts a long shot above the favorite. You check the sorting function. It's fine. The damage happened before the rows reached it.
A field named homeMoneyline looks reassuringly numeric. But the Actor preserves published prices, including fractional strings. Applying parseFloat before identifying the notation can reverse your implied-probability ranking.
Example: this assertion shows a fractional long shot incorrectly outranking an American-priced favorite after a permissive conversion.
import assert from 'node:assert/strict' ;
const americanProbability = ( price : number ) => price > 0 ? 100 / ( price + 100 ) : - price / ( - price + 100 ) ;
const fractionalLongShot = '20/1' ; const americanFavorite = - 110 ;
assert . ok ( americanProbability ( parseFloat ( fractionalLongShot ) ) > americanProbability ( americanFavorite ) , ) ;
Enter fullscreen mode
Exit fullscreen mode
Nothing throws.…