Below is the script to count the maximum x from the list as below, but I am facing an issue counting the y, it's always getting the wrong result.
am think ( if am not wrong ) that the function still counting the X instead of Y.
Would you please look at it and reply to me?
Thank you so much for your attention and participation.
Code: Select all
list=
(
500,600
500,700
500,800
600,800
600,600
600,700
600,800
600,900
)
Msgbox % Get_MAX(List) ; Result 600 as 600 counts 5 times on the list on x.
Get_MAX(List)
{
items := {}
Loop, parse, list, `n, `r
{
StringSplit, p, A_LoopField, `,`
RegExReplace(list,"`am)^" p1,"",x)
items[p1] := {Count:x}
}
For x,obj in items
XX .= obj.count "," x "`n"
Sort, XX, R
list=
Loop, parse, XX, `n, `r
{
if A_Index = 1
{
HighestValue := A_LoopField
HighestValue := RegExReplace(HighestValue,".,")
}
}
return % HighestValue
}
ExitApp