/    Sign up×
Community /Pin to ProfileBookmark

An elegant way to mix arrays arrays…

Hi !

I am looking for an elegant way to mix arrays arrays.

I admit i am fairly proud to have found the hereunder script. Unfortunately,
it breaks the lines.

Thanx for your help !

[code=php]
array=[
[‘Bernard’,’Bernard’],
[‘Jean’,’Jean’],
[‘Jocelyne’,’Jocelyne’],
[‘Maud’,’Maud’],
[‘Rudolf’,’Rudolf’]
]

function aleate()
{
return Math.pow(-1, Math.round(2*Math.random()))
}

alert(array.sort(aleate))
[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsMar 06.2005 — JavaScript?!?!

JavaScript doesn't have the greatest support for arrays

[url=http://www.php.net/manual/en/ref.array.php]PHP Array Functions[/url]
Copy linkTweet thisAlerts:
@Grand_MamamouchauthorMar 07.2005 — Excellent piece of news !

My function

[code=php]function aleate()
{
return 2*Math.random() -1
}
[/code]


in the end respects the inner arrays !

Happy day !
×

Success!

Help @Grand_Mamamouch spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...