Jump to content

Recommended Posts

Posted (edited)

I've been searching for a solution on the forum and came across a partial solution in this topic...

My problem is that I have a 2D array; column one has the description (a string) of the integer in column two. I want to sort this array by the value of column two from highest to lowest. Only my _ArraySort produces a strange result.

Here is the code and the output before and after...

Local $PensionsOne = ($MonthlyPensionIncomeOne + $MonthlyPensionCreditIncomeOne)
Local $SecondEmploymentOne = ($SecondSalaryOne + $SecondBonusOne + $SecondOvertimeOne + $SecondCommissionOne)
Local $aGetHighestFiveAdditionalIncomesForAppOne[8][2] = [ _
   ["Occupational pension income", $PensionsOne], _
   ["2nd job", $SecondEmploymentOne], _
   ["Working Tax Credits", $MonthlyUniversalTaxCreditIncomeOne], _
   ["Disability living allowance", $MonthlyStateDisabilityIncomeOne], _
   ["Investment or dividend income", $MonthlyInvestmentIncomeOne], _
   ["Maintenance", $MonthlyMaintenanceIncomeOne], _
   ["Rental income", $MonthlyUnencumberedRentalIncomeOne], _
   ["Self-employed income", $SecondNetPreTaxProfitLatestYrOne]]

_ArrayDisplay($aGetHighestFiveAdditionalIncomesForAppOne)
_ArraySort($aGetHighestFiveAdditionalIncomesForAppOne, 0, 0, 2)
_ArrayDisplay($aGetHighestFiveAdditionalIncomesForAppOne)

 

Before.PNG

After.PNG

Edited by Dent
Solved
Posted

I believed I had already changed the strings to integers, here is a sample of the code I've used...

$MonthlyInvestmentIncomeOneRaw = _ArrayToString($aArray, ":", 93, 93)
Local $MonthlyInvestmentIncomeOneStart = StringInStr($MonthlyInvestmentIncomeOneRaw, ":")
Local $MonthlyInvestmentIncomeOne = StringMid($MonthlyInvestmentIncomeOneRaw, ($MonthlyInvestmentIncomeOneStart + 1), 8)
StringFormat("%i", $MonthlyInvestmentIncomeOne)

 

Posted
Just now, Jos said:

I don't see you filling the cell for $aGetHighestFiveAdditionalIncomesForAppOne in there.
How are the values put in?

Jos

The code in my original post shows the values being input into the array.

  • Developers
Posted

I saw that after posting ....sorry.

so do something like:

Local $aGetHighestFiveAdditionalIncomesForAppOne[8][2] = [ _
   ["Occupational pension income", Number($PensionsOne) _
...

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...