View Single Post
  #1  
Old 11-03-2010, 04:51 AM
MrOmega MrOmega is offline
One More Time
MrOmega's Avatar
Join Date: Aug 2010
Location: TN, USA
Posts: 631
MrOmega is an unknown quantity at this point
Send a message via AIM to MrOmega Send a message via MSN to MrOmega Send a message via Yahoo to MrOmega
SortBubble( array, collation)

Well, redid this script and used the bubble method of sorting, simple to understand.

parameter:
1st - Array to Sort
2nd - Collation to use, if NULL it will use AlphaNumeric Collation

Script:
PHP Code:
function sortBubbletemp.list, temp.order)
{

  if ( !
temp.order)
  {
  
    
temp.order 
    {  
  
      
"`""~""!""@""#""$""%""^""&""*""("
      
")""-""_""=""+""[""{""]""}""|"";"
      
":"",""<""."">""/""?""0""1""2""3"
      
"4""5""6""7""8""9""A""a""B""b""C"
      
"c""D""d""E""e""F""f""G""g""H""h"
      
"I""i""J""j""K""k""L""l""M""m""N"
      
"n""O""o""P""p""Q""q""R""r""S""s"
      
"T""t""U""u""V""v""W""w""X""x""Y",
      
"y""Z""z"
    
    
};
  }
  
  for ( 
temp.0temp.< ( temp.list.size() ^ 2); temp.++)
  {

    if ( 
temp.swap)
    {
    
      
temp.=
      
temp.swap NULL;
      
    }

    if ( (
temp.1) == temp.list.size())
      break;

    
    while ( 
temp.obj1 == temp.obj2)
    {

      
temp.obj1 = ( @ temp.list[ temp.a]).substringtemp.start1);
      
temp.obj2 = ( @ temp.list[ temp.1]).substringtemp.start1);
      
temp.start ++;
      
      if (( @ 
temp.list[ temp.a]) == ( @ temp.list[ temp.1]))
        break;

    }

    if ( 
temp.order.indextemp.obj1) > temp.order.indextemp.obj2))
    {

      
temp.swap temp.list[ temp.a];
      
temp.list[ temp.a] = temp.list[ temp.1];
      
temp.list[ temp.1] = temp.swap;

    }
    
    
temp.obj1 
    
temp.obj2 
    
temp.start NULL;

  }

  return 
temp.list;

Usage:
PHP Code:
sortBubble( {"a""0""aa""a""How""Now""Brown""Cow""?""A""a"}) 
would give you this
PHP Code:
{"?","0","A","a","a","a","aa","Brown","Cow","How","Now"
__________________
Time is the fire in which we burn...
Up, Up, Down, Down, Left, Right, Left, Right, B, A, Select, Start! Now I got 99 LIVES!!!
Reply With Quote