Weird sorting behavior in AS

Consider the code:
var a:Array = new Array();
a.push({str:"a", val:2});
a.push({str:"b", val:3});
a.push({str:"c", val:2});
a.push({str:"d", val:2});
a.push({str:"e", val:3});
a.sortOn("val", 16);
for (var i:int=0; i<=4; i++){
trace(a
.str + " -- " + a.val);
It outputs:
c -- 2
d -- 2
a -- 2
b -- 3
e -- 3
Why does it change the original order - shouldn't the output
be a,c,d,b,e - whereas the output is c,d,a,b,e? I tried it in both
AVM1 and AVM2.
Any clues would be greatly appreciated.
Thanks,
Pallav

i don't think you can guarantee the order of sorted elements
where the field you're sorting on is equal. for example, if you
sortOn val again, the order changes again:
a -- 2
d -- 2
c -- 2
b -- 3
e -- 3
if you need it to retain original sort order where sort
fields are equal you may have to write that sort routine yourself.
alternatively, if it helps you could sort on two fields:

Similar Messages

  • IPhone 6 Plus weird screen behavior

    I recently started noticing some erratic touch behavior on my screen, it's as if I have a possessed phone such as taps that I did not make, or swipes (up/down/left/right) as well. The spotlight randomly swipes down, or the notification center (it seems like a consistent swipe down behavior but at different locations). I couldn't swipe left yesterday to unlock my phone, and sometimes hangs and only locking/unlocking can fix the unresponsiveness.
    Moreover, random tappings affect games and apps such as whatsapp, where it goes to the previous page due to a top left page tap, and then again on the edit button, then starts randomly scrolling up and down and tapping random parts of the screen.
    This is quite frustrating, I tried formatting and starting the phone as a new one and only installed Whatsapp, but the problem persisted, albeit at fewer occurrences.
    Now I noticed the problem again even though I'm on iOS 8.1, with only apps, music, and photos synced back from iTunes. What is happening ? How can I get this fixed ?
    Summary
    Issue :
    Erratic touch behavior which cannot be produced on demand
    Rare screen unresponsiveness following the weird touch behavior
    What I've tried :
    Reset and start phone as New
    Reset all Settings
    Hard Reset
    Currently using a sketching app to see how the screen taps randomly (for proof as well).

    Hello zazu90,
    Thanks for using Apple Support Communities.
    To troubleshoot this issue where your touchscreen is behaving erradically on your iPhone, please follow the steps below.
    Restart your device
    Hold the On/Off button until "slide to power off" appears. Slide to power off your device. When it is off, press the On/Off button to turn it back on.
    If you can't restart your device, reset it by pressing and holding the Sleep/Wake button and the Home button at the same time for a least ten seconds, until the Apple logo appears.
    Clean the screen with a soft, slightly damp, lint-free cloth.
    Avoid using the device while wearing gloves, with wet hands, or immediately after applying hand lotion.
    If you have a protective case, or if you are using a plastic sheet or film on the display, try removing them and testing the device without it.
    If the steps above don't resolve your issue, please schedule a service appointment with an Apple Retail Store for evaluation. If an Apple Retail store is not an option, contact Apple to find out your best service option or see the Service FAQ for your product.
    iPhone, iPad, iPod touch: Troubleshooting touchscreen response - Apple Support
    Take care,
    Alex H.

  • Weird keyboard behavior PS CS3

    Hi all,
    Every now and then it seems like my keyboard has gone nuts.
    This always happens inside PS CS3. After doing some actions, especially when doing a 'Shift-Alt-Arrow key' action (duplicating a layer or group and moving), it looks as if the keyboard goes in some sort of 'Alt-Always-On' modus.
    The annoying thing about this is, that regular keyboard-shortcuts for selecting a tool don't work (pressing 't' for the type tool does nothing) but far worse is the fact when you want to move a layer or group of layers they get unwantedly duplicated.
    Sometimes this behavior seems to disappear, when I click around my desktop (outside of Photoshop), but sometimes it doesn't disappear. The only thing left to get rid of it is to quit and relaunch PS.
    Does anyone else have this problem, and how can it be solved.
    This weird keyboard thing does only appear in PS, every other application is not affected by it.
    I'm running PS CS3 on Windows XP SP3
    I have all updates of PS CS3 installed

    Zeno,
    I feel so stupid, but that also crossed my mind.
    And to be honest, I think that is really the reason.
    Why didn't I think of that before...

  • Lion produces weird trackpad behavior in Angry Birds

    I upgraded to Lion this week. I know there are all sorts of new trackpad features, but the probem is that it messes up a lot in Angry Birds. For example, the various finger-swipes have unpredictable results; instead of resetting the screen, it might activate launchpad. Or it might jump you back to the "play" splash screen. The pinch and expand gestures might randomly activate mission control instead of zooming the way it did in pre-Lion Angry birds. And quite often, I'm finding that the trackpad stops responding at all! No matter what gesture I use, the bird sits there in the slingshot, unmoved, unless I restart the app. It's weird.
    I've adjusted the trackpad settings in Settings as much as possible to accommodate gameplay, but AB still responds unusually to gestures, without regard to either the specified setting or to its pre-Lion performance. It seems like Apple put way too many features into every slight gesture on a trackpad, so it's become LESS intuitive because gameplay gestures trigger spontaneous resets and screen modifications instead of, well, game interaction.

    Works for me and thanks i just try to see because i didn't play in Lion and the level that i was stuck in i pass it in the first try so thank you it works for me.But is true playing that game you can't do much gestures same thing happening before lion,just open it play it and close it.

  • Weird keyboard behavior in MacBook Pro 13'

    Hi guys, I have a MacBook Pro that's starting to show a strange keyboard behavior.
    The problem is that the keys: e r t y u i o (curiously all belong to the same row) sometimes get unresponsive.
    It's very annoying of course and it happened about 4 months after upgraded to Lion.
    The geneal perfomance of the laptop was deteriorated and I've read that a clean install of Lion might help so I've did it thinking that it will also fix any OS weirdness about the keys too.
    The machine works way better after the clean Lion install but the problem of those same keys persist.
    What I did next was to reset the PRAM thinking it might be interference from some weird state there. But after the reset the problem persisted.
    Curiously, I've figured out that when, for example the i key gets unresponsive, if I press AND hold the e key then the i key works totally fine (think of typing an "I" but using e instead of shift).
    If, when pressing the unresponsive keys, I use different angles or quantity of force in the pressure of the keys or cornes of the key the behavior stays the same. The only thing that seems to affect is holding the e key down before pressing it. Every time it gets weird I do it and it kind of get normal for a while.
    Also, sometimes, keeping some seconds the unresponsive key ends up getting responsive again (but not always).
    This mac has about two years now and it's very well preserved.
    Do this happen to anyone? ideas?
    Is there some other thing than PRAM I could reset to see if it gets normal again?

    You are making me dig into nightmare-ish memories here.
    Ok, I'll share.
    This is how turned out:
    Needed to send my MBP to another town with an Apple authorized service provider and asked to change the keyboard for a new one.
    It was ~20 days waiting until they got the new keyboard part from Apple and about ~3 more to get it fixed and ~2 more to get it again in town.
    I received it very well packaged and all was fine after that but the whole thing was very expensive, ~40% of the price I paid for the whole MPB in the first place plus all that time without being able to use it.

  • Weird Battery Behavior in 7.1.1

    Has anyone else noticed weird behavior after upgrading to 7.1.1 - on my 5s its not that the battery is draining quickly - in fact its showin 5 hours 40 minutes usage with 75% remaining - which i find hard to believe
    whats weird is standby time equals the usage time but i have turnd off and aback on the iPhone - I even did a hard reset - i have a monitor program which is showing the cpu as mostly idling at 90% or more ( although the monitor probably doesnt know about the M7 chip - it probably doesnt even know about the A7 chip too)
    The battery percentage is not going down quickly - it seems to be thr same rate as with 7.1 but i dont believe these numbers
    Im going to let the battery drain completely and do a battery calibration - that some times helps after IOS upgrades
    But i was wondering if anyone else was seeing this and had any suggestions

    Grant Hiesterman wrote:
    Out of curiousity, how were the issues fixed/resolved other the past?  With IOS updates? Other?
    The problem has always been an errant app that got stuck in a loop. It can happen any time, but is more likely to happen right after an update. My hypothesis is that the update process suspends running apps, and sometimes after the update they "lose their place" and spin their wheels trying to find it. (It's easier to say it that way then to talk about race conditions.) What will frequently fix it is to run the battery all the way down until the phone shuts off. This terminates all processes, even those that cannot be killed from the Quick Launch screen.
    You can also try to find the app; if it's email turning off any Push email accounts, rebooting, and turning them back on will frequently fix it. If it's a 3rd party app killing all apps in the Quick Launch will frequently fix it.
    Sometimes just turning off the phone for a few minutes will fix it.
    Restoring the phone as new will usually fix it, but restoring from backup may not, because the app state may be preserved in the backup.
    It really just a matter of trying things like these one at a time. One of them will work.
    Do you or Trevor have a CPU monitoring app you believe is a quality application?
    I've tried several, and haven't found any that I like. I like Trevor's answer.

  • Not a real problem anymore, but a weird Apache behavior wrt .php files

    Hello everyone. Yesterday I was trying to set up an ordinary LAMP server in my VPS, running Arch (first time ever touching apache). After all was said and done, and apache and PHP were correctly configured following the Arch Wiki, I tried to get some things like phpmyadmin and ampache running, but I found out that my browser was asking me to download either a login.php file or an index.php file (to be more specific: I added a test.php file in /srv/http and that was interpreted correctly and I could see all the information as intented; if i pointed my browser to /phpmyadmin or /ampache though I would see the first page but after trying to, for example, logging in with phpmyadmin I'd get the download prompt). I googled around and yes, everything was configured as it should have, I had the AddHandler directive in the apache conf file and all that jazz. This morning, I log in, I start apache (since it wasn't working I figured that I might as well shut it down for the night and yes, while testing and setting up things yesterday I restarted the daemon every time) and everything works as it should: ampache lets me create my configuration, phpmyadmin lets me see my DBs and everything works. So, the problem apparently fixed itself, or at least the weird behavior I was witnessing is no more. Is there any specific reason for this? I wouldn't want to start from scratch (and I probably will, since I like to mess up a lot, that's how i learn!) to perhaps find myself in this spot again and not know what to do!
    Last edited by mrz87 (2011-05-11 09:12:21)

    This was a problem with apache-2.2.17-2. Don't worry, it's fixed for good.
    https://bugs.archlinux.org/task/24208

  • How to change sorting behavior in column view in Lion Finder?

    I love the ability to sort in column view in OS X 10.7. However, when I switch to column view and let sort by label, the Finder displays a strange behavior: The files are grouped by label, but in the order of lee to more. It does not seem possible to display according to the label order set in the Finder prefs.
    This is somewhat irritating. Is there a way to change this can make it consistent to the label order?
    The label order in the Finder was set to "Prio A", then "Prio B" and so forth.

    If I set it to "Arrange by", I get them sorted by file name, irrespective of the color.
    If I change that in the View Options, I get them sorted according to label, but not in the label order of the Finder prefs.

  • Unpredictable sort behavior in generic Rowset pageflow?

    Has anyone else noticed somewhat random behavior for the sort functionality of
    columns in a grid from a RowSet based Pageflow. I generated a page flow in workshop
    based on a simple RowSet control. Clicking on a column will often leave the column
    partially sorted. Clicking on it again will reverse the sort direction and it
    seems to then be sorted correctly. Clicking again reverses the sort direction
    and it seems to be sorted correctly.
    The error or odd behavior happens when you switch sort columns or first change
    the sort order. The data I have is just complicated enough to make it difficult
    to tell what might be happening. Did I miss some feature in the documentation
    or is this a known bug?
    thanks,
    Morgan

    Thanks again Morgan. Please do let us know if you are able to reproduce this
    behavior.
    Regards,
    Raj Alagumalai
    WebLogic Workshop Support
    "Morgan Hall" <[email protected]> wrote in message
    news:[email protected]..
    >
    Update:
    I quickly created a sample table with 3 columns: number(int), letter(char10),
    complex(varchar 50) in SQL Server 2000. Using this table I generated arowset
    control and then built a pageflow from it.
    I added numbers 1-26 in the first column, z-a in the second, and z1 - a26in the
    third.
    1 z z1
    2 y y2 etc...
    In this test case, the sorting works perfectly so I'm not sure what aboutmy other
    tables causes the issues. If I determine better means to duplicate theproblem
    I'll post them.
    Morgan
    "Morgan Hall" <[email protected]> wrote:
    Has anyone else noticed somewhat random behavior for the sort
    functionality
    of
    columns in a grid from a RowSet based Pageflow. I generated a page flow
    in workshop
    based on a simple RowSet control. Clicking on a column will often leave
    the column
    partially sorted. Clicking on it again will reverse the sort direction
    and it
    seems to then be sorted correctly. Clicking again reverses the sort
    direction
    and it seems to be sorted correctly.
    The error or odd behavior happens when you switch sort columns or first
    change
    the sort order. The data I have is just complicated enough to make it
    difficult
    to tell what might be happening. Did I miss some feature in thedocumentation
    or is this a known bug?
    thanks,
    Morgan

  • Weird sort order in Mail

    Mail is sorting my messages very strangely. For example, I have a folder with about 2000 messages ranging from sometime in 2004 until this morning. When iPhone Mail pulls it up the first page of messages is from sometime in late 2006. It gets the total number right, so I think it's seeing everything...it's just picking a weird (and not particularly useful) timeframe to show.
    Any idea what might be going on - and, more importantly, how to fix it?

    I can't help you, but I join you with the same problem ....
    Mail downloaded from some time in the past ...
    But only for sent folder. In .mac my sent folder actually orders the mails strangely too as opposed to my trash folder that in both the iphone and .mac are ordered properly.
    Anyone any help?

  • Weird compression behavior

    I have been trying to compress some animation material for DVD. It is mostly flat colors with black outlines. The past few weeks I've been having trouble exporting to compressor via Final Cut (the connect to background process bug) and so I have been using reference movies loaded into Compressor standalone.
    I am seeing weird behavior, though. When I compress the reference movie, the frames look fine although every now and then there are artifacts, pieces of the image that break down. I think of them as compression errors, and I suspected that the compression markers at the beginning of each clip were not being exported in the reference movie.
    So I tried a few things and finally got Final Cut to connect to compressor directly. This worked in that the compression errors I was seeing are gone--HOWEVER, the overall quality of the encode has decreased markedly! The black lines around shapes are all jagged, and the whole image looks inferior to the one compressed in Compressor standalone.
    The thing is, both of these were compressed using the exact same preset! Does anyone know what the deal is? I would like to get the image quality from the standalone Compressor encode, but without the artifacts.
    Thanks for any advice,
    Bob

    Your mileage may vary with Compressor 2. Some like it, some don't.
    As for your original question, I've never seen unexplained changes like what you describe in a preset's behavior with FCP HD and/or Compressor 1.2.1.
    As for the "unable to connect to background process" problem I've seen that once in just over one year of use with Compressor and Final Cut. On this one occasion I just manually relaunched QMaster and everything was fine from then on.

  • Strange stacks icons and weird dock behavior

    I got leopard for Christmas and on the first day of the install my icons on the right side of the dock- i guess the stacks for applications and downloads icons look weird. It's not a combination of all the icons in the stack like someone else wrote, it is a weird green, white, red rectangular shaped image with weird black and grey squiggles going through the middle. Also-I'm not sure how to describe it but what used to be a clear line I guess to separate the stacks stuff with the other icons on my dock it's next to about this mac icon on my dock has turned into a weird pink rectangle with a really small picture of the weird red, green, and white rectangle on top. Any help would be greatly appreciated. My husband is a windows guy and after me bragging about how much better mac is, I don't want him to know that I'm already having problems with leopard

    No, this is not "normal behavior." The problem is that it is not consistent, either, so it is hard to tell what is going on. It may happen after using some full screen programs, but I am not sure. I am not able to reproduce the issue, myself. It just happens from time to time.
    The icons are not changing after they are used. The ones in the download folder will usually have their normal appearance, the dmg file or a pdf file with its "preview" icon or whatever. Then, for some reason, I will notice some of the icons have become blocky and pixilated, not resembling anything, usually almost a solid color.
    Again, the way to get them to change back is to remove the downloads folder from the doc and return it. Then all the icons return to their normal view.

  • Weird application behavior - solution

    I recently had a major series of disk meltdowns. I suspect part of the problem may have been caused by letting my startup disk get too full and working with very large photoshop files (with photoshop using the startup disk as a scratch disk). Anyway, I managed to restore a clone of my startup drive, update all apps, and get back to work. I've cloned the startup drive to my second internal drive and intend to religiously update the clone whenever I update any applications (we'll see if I return to agnoticism). Anyway, several applications had weird behavior. Cleaner would succesfully compress one file and then quit. I could then restart cleaner and the batch list had successfully updated but again, just one compression and then a quit. DiskWarrior would successfully rebuild a drive directory but then quit without any notice. Today, I restarted from my cloned startup drive and ran diskwarrior on my main startup drive. Problem solved. Figured a few people out there might benefit from my experience.

    Michael,
    Often, the Quits are caused by a corrupt Property List file. When a number of apps have the Quits, that's another story. Back in v10.2, that was often caused by a hidden user prefs file
    (~/Library/Preferences/.GlobalPreferences.plist) where ~ is your user Home folder. You could try deleting it in Terminal, but I haven't heard of this causing these problems since Jaguar.
    Maybe you could try creating a new user Account, log into the new Account and see if things improve. At least that would prove whether the cause has something to do with user prefs, including that hidden global prefs file.
    I'm thinking it's a hardware problem, though.
    EDIT: FWIW, here is the step-by-step for deleting that global prefs file and replacing it with a fresh copy:
    1) Log in as an Administrator.
    2) Create a new user account, called NewUser.
    [The name isn't important, because you're going to delete this account when we're done].
    2b) If the affected user account is not an administrator account, go ahead and make it one. You can revoke this privilege later, but it will make things easier for now.
    3) Log out, and log back in as NewUser.
    [This will initialize the account and create undamaged preferences.]
    4) Log back out, and log in again as the user affected by the crashed (who, according to step 2b, is an Administrator).
    5) Launch the "Terminal" application, located in /Applications/Utilities/
    6) Type the following command (for all of the following, copy and paste):
    cd ~/Library/Preferences/
    7) Type this command:
    rm .GlobalPreferences.plist
    8) Type this command:
    sudo cp /Users/NewUser/Library/Preferences/.GlobalPreferences.plist .
    [it will ask for an administrator password to allow you to log in as root for this action]
    9) Type this command -- DON'T COPY-PASTE THIS ONE! YOU NEED TO PUT YOUR OWN USERNAME:
    sudo chown USERNAME .GlobalPreferences.plist
    10) Log out.
    10b) If you enabled Admin access on an account that shouldn't have it, log back in as an Administrator and disable that Admin access.
    11) Delete the NewUser account.
    12) Log out, and log in to the affected acount.
    There will be some System Preferences you'll need to reset afterwards.

  • Weird textinput behavior embedded font

    I have this weird behavior with an embedded font in a textinput.
    I have embedded the myriad font and aplied it on a textinput.
    In this weird scenrio when i type "test configuration" in the textinput and then pres the left arrow key the cursors will not go further back than the letter n in the word configuration.
    This behavior is only with some font types, like myriad or ubuntu.
    Since i have no clue how to upload attachments to this forum i created a Box link
    https://www.box.com/s/0boj6u2kgmwojbg9ubhd
    In here i have a video of the behavior and a test project.

    Not sure if this will help you, but in order to get my embedded fonts to render, I had to do:
                    GlobalSettings.resolveFontLookupFunction = null;
                    //setup text item from xml
                    var res:XML = XML(xml.htmlText.children()[0]);
                    var tf:TextFlow = TextFlowUtil.importFromXML(res,WhiteSpaceCollapse.PRESERVE);
                    tf.renderingMode = RenderingMode.CFF;
                    tf.fontLookup = FontLookup.EMBEDDED_CFF;
                    txt.textFlow = tf;
                    txt.textFlow.whiteSpaceCollapse = WhiteSpaceCollapse.PRESERVE;
                    txt.textFlow.invalidateAllFormats();
    The important lines ar the first and last.

  • DataGrid paging, how do I override sorting behavior?

    I've got a large dataset and I'm showing pieces of it at a
    time in a DataGrid. When the user clicks a heading in the grid to
    sort the data, I don't want the DataGrid to sort it. Instead, it
    needs to reload the data from the server and tell the server how to
    sort it. How might I go about overriding the default behavior for
    heading clicks? If only there was some sort event for the
    grid…

    There's a protected method of the DataGrid placeSortArrow()
    that "draws the sort arrow graphic on the column that is the
    current sort key." Is there a way to tell the DataGrid which column
    is the current sort key from my headerRelease event handler? Then
    would I have to call the placeSortArrow method somehow? It's a
    protected method, so could I call it if I extended the DataGrid and
    called it from my custom DataGrid?
    Or am I better off appending a symbol to the end of the text
    of the header that's clicked?

Maybe you are looking for

  • Creating directories for installing Oracle Application Server 10.1.2.0.2

    Hi, I have Red Hat Linux 4.0 and i am trying to install OAS 10.2.0 Enterprise Edition which includes web tier, app tier and database tier all in server machine because i do have about 100GB disk space, 12 GB memory and 9 GB swap space. Now, i read th

  • Poor Sound

    Has any one experinced poor sound quality with 5th gen ipod when playing back through a hifi...

  • EJB-QL with self referencing cmr-field in path identifier fails

    I have a simple application . Only one bean and one relationship. The relationship is a (0..1)-(0..1) for the same bean (self referencing). I have a finder method defined with ejb-ql that tries to access the field of one of the cmr fields of the rela

  • QuickTime 7.4.1 in Leopard 10.5.2 NOT WORKING

    Hangs interminably on opening; web link yields huge question mark. No web files will play (e.g., Apple movie trailers). Have purged all QuickTime elements, have reinstalled, etc. No help. You can drag and drop movies on my drive to the program, and i

  • My phone won't sync to my MacBook anymore! Please help!

    Ever since this whole iCloud thing has been out, every time I plug my phone into my MacBook, it'll "sync," but none of my calendar events from my phone will sync onto my iCal.  Before iCloud, every time I plugged my phone in, anything that would be o