import * as _ from "lodash" ; const VERSION_VALUE_MAX = 999 ; const VERSION_VALUE_DIGITS = 3 ; export function getSortText ( version ) { const segments = version . split ( /\.|-/ ) ; const [ major , minor , patch ] = segments . map ( x => Number . parseInt ( x , 10 ) ) . map ( x => Number . isInteger ( x ) ? x : 0 ) ; return [ major , minor , patch ] . map ( v => _ . padStart ( ( VERSION_VALUE_MAX - v ) . toString ( ) , VERSION_VALUE_DIGITS , "0" ) ) . join ( "" ) ; }