Here is an array that needs to be sorted:
var baseBetAmount = [
{
val: 'OtherBaseBet',
text: 'Other'
},
{
val: 0.10,
text: '$0.10'
},
{
val: 0.20,
text: '$0.20'
},
{
val: 0.50,
text: '$0.50'
},
{
val: 1,
text: '$1'
},
{
val: 2,
text: '$2'
}]
I have tried to sort it using the following function:
var options= _.sortBy(baseBetAmount)
The output after sorting looks like this:
[
{
val: 'OtherBaseBet',
text: 'Other'
},
{
val: 0.1,
text: '$0.10'
},
{
val: 0.2,
text: '$0.20'
},
{
val: 0.5,
text: '$0.50'
},
{
val: 1,
text: '$1'
},
{
val: 2,
text: '$2'
}]
However, the issue is that numbers such as 0.10 are being replaced by 0.1 in the sorted array. I need help to prevent this from happening.