Jump to content
php.lv forumi

Recommended Posts

Posted

Sveiki

 

Man ir masīvs

$array=array(
[1]=>523,
[2]=>125,
[4]=>742,
[6]=>32,
[12]=>45,
[32]=>322
);

 

Vēlos lai tiktu nosortēts lūk šādi

$array=array(
[4]=>742
[1]=>523,
[32]=>322,
[2]=>125,
[12]=>45,
[6]=>32
);

Posted

Kaut vai elementārāko metodi pielieto:

1. Atrod lielāko masīva "x" vērtību.

2. Ieliekam šo vērtību jaunā masīvā "y".

3. Izdzēšam šo vērtību no datu masīva "x".

4. Ejam cauri šiem trim soļiem, kamēr masīvs "x" ir tukšs.

5. Rezultātā tiek iegūts jauns masīvs "y" ar jau sakārtotām vērtībām.

6. Izvadam masīvu "y".

Posted

phpjanis, nemāci cilvēku uz muļķībām. Tam ir iebūvētās PHP funkcijas (skat vienu komentāru pirms tavējā). Divritenis nav jāizgudro.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...