N
NiQ
Hello every one,
this is about an array of string and may be have done several time
before but i need it and wasnt able to find it so here is the problem
i have an array of strings with contains words and i want a distinct
list of array with the count of each number repeat i.e how many time
it exist in the array and the final result should be sorted according
to the number of repeat from hight to low .
for example
thearray="32a,7s,5a,29s,20,29s,32a,8,5a,32a,32a,32a"
the result should be
32a
29s
5a
7s
20
8
i have this code which take out all the duplicate values and print the
distinct values
function RemCDups(byVal thearray)
Dim element,element2,k,i,j
dim newArray()
redim newArray(0)
for i = 0 to ubound(thearray)
element = thearray(i)
element2 = "false"
for j = i + 1 to Ubound(thearray)
if theArray(j) = element then
element2 = "true"
end if
next
if element2 = "false" then
redim preserve newArray(Ubound(newArray)+1)
newArray(k) = theArray(i)
k = k + 1
end if
next
RemCDups = newArray
end function
but i want to modify it to do the sort according to the count of each
element from high to low
thanks.
regards
NIQ
this is about an array of string and may be have done several time
before but i need it and wasnt able to find it so here is the problem
i have an array of strings with contains words and i want a distinct
list of array with the count of each number repeat i.e how many time
it exist in the array and the final result should be sorted according
to the number of repeat from hight to low .
for example
thearray="32a,7s,5a,29s,20,29s,32a,8,5a,32a,32a,32a"
the result should be
32a
29s
5a
7s
20
8
i have this code which take out all the duplicate values and print the
distinct values
function RemCDups(byVal thearray)
Dim element,element2,k,i,j
dim newArray()
redim newArray(0)
for i = 0 to ubound(thearray)
element = thearray(i)
element2 = "false"
for j = i + 1 to Ubound(thearray)
if theArray(j) = element then
element2 = "true"
end if
next
if element2 = "false" then
redim preserve newArray(Ubound(newArray)+1)
newArray(k) = theArray(i)
k = k + 1
end if
next
RemCDups = newArray
end function
but i want to modify it to do the sort according to the count of each
element from high to low
thanks.
regards
NIQ