Sign in to follow this  
Followers 0

Quick _ArraySort Question

2 posts in this topic

#1 ·  Posted (edited)

I'm making separate arrays containing a. song titles in itunes and b. the corresponding artists.

eg $titles[1] = "all my loving" $artists[1] = "the beatles"

I want to sort the song titles alphabetically using the _ArraySort udf, but won't that mean that the artists will no longer match, and if I sort the artists the order will be completely different?

I'm looking for a simple way around that.

Any ideas?

Edited by yaziquex

Share this post

Link to post
Share on other sites


does this work? I tried it. :">

; Array Sort

Global $song[4] = ["Ein bißchen Frieden", "Skater Boi", "Supreme", "Hello again"]
Global $artist[4] = ["Nicole", "Avril", "Robbie Williams", "Howard Carpendale"]

_ArrayDisplay($song, "Song")
_ArrayDisplay($artist, "Artist")
_sort($song, $artist)
_ArrayDisplay($song, "Song")
_ArrayDisplay($artist, "Artist")

Func _sort(ByRef $Master_A, ByRef $Slave_A, $i_Descending = 0)
    If UBound($Master_A) <> UBound($Slave_A) Then Return -1
    Local $sort_A[UBound($Master_A) ][2]
    For $i = 0 To UBound($Master_A) - 1
        $sort_A[$i][0] = $Master_A[$i]
        $sort_A[$i][1] = $Slave_A[$i]
    _ArraySort($sort_A, $i_Descending, 0, 0, 2, 0)
    For $i = 0 To UBound($sort_A) - 1
        $Master_A[$i] = $sort_A[$i][0]
        $Slave_A[$i] = $sort_A[$i][1]
    Return 1
EndFunc   ;==>_sort

So long,


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post

Link to post
Share on other sites

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
Sign in to follow this  
Followers 0