/    Sign up×
Community /Pin to ProfileBookmark

The Superiority of Microsoft Iternet Explorer JS Sort function

Open for discussion [NO flaming allowed]

jsfiddle: [url]http://jsfiddle.net/sxxzhLxd/[/url]

[code=html]<!DOCTYPE html>
<html>
<head>
<style>
div div { padding: 1px 1em };
</style>
</head>
<body>
<div id=test>
<div style=”background-color:yellow”>B</div>
<div style=”background-color:yellow”>D</div>
<div style=”background-color:yellow”>A</div>
<div style=”background-color:yellow”>C</div>
<div style=”background-color:yellow”>E</div>
<div style=”background-color:orange”>B</div>
<div style=”background-color:orange”>D</div>
<div style=”background-color:orange”>A</div>
<div style=”background-color:orange”>C</div>
<div style=”background-color:orange”>E</div>
<div style=”background-color:red”>B</div>
<div style=”background-color:red”>D</div>
<div style=”background-color:red”>A</div>
<div style=”background-color:red”>C</div>
<div style=”background-color:red”>E</div>
</div>
<input type=button value=”Sort” onclick=”dosort()”>

<script>

function dosort() {
var i = 0,
elements = [].slice.call(test.children).
sort(function (a, b) {
if (a.innerText < b.innerText) return -1;
});
while (elements[i])
test.appendChild(elements[i++]);
}

</script>
</body>
</html>[/code]

to post a comment
JavaScript

19 Comments(s)

Copy linkTweet thisAlerts:
@Troy_IIIauthorJan 30.2015 — Since Firefox is still "avoiding" support for HTML5 Standard "innerText" property - here is a version using textContent...

Fiddle: http://jsfiddle.net/sxxzhLxd/1/
Copy linkTweet thisAlerts:
@jedaisoulJan 30.2015 — What is there to discuss? Where is your argument? Superior to what?
Copy linkTweet thisAlerts:
@Troy_IIIauthorJan 30.2015 — As you've already noticed, obviously:

Superior to any other existing UA's in use (to date), considering JavaScript 'stable' [B]sorting [/B].
Copy linkTweet thisAlerts:
@jedaisoulJan 30.2015 — Are you saying that your method of sorting:

a) Has not been thought of before?

b) Is superior to any other existing stable JavaScript UA?
Copy linkTweet thisAlerts:
@Troy_IIIauthorJan 30.2015 — As it appears, you don't seem understand the Spartan idiom used in the code.

Would you like me to step-comment it?
Copy linkTweet thisAlerts:
@jedaisoulJan 30.2015 — That's all right, I just wanted to clarify what the thread was about, as it was not clear to me from the OP.
Copy linkTweet thisAlerts:
@Troy_IIIauthorJan 30.2015 — And "no",- I didn't Invent the [B]Array.sort( [ method ] )[/B] - it's in JavaScript since like,... forever.
Copy linkTweet thisAlerts:
@jedaisoulJan 30.2015 — Can you clarify what is original in your sort, and what IE has to do with it?
Copy linkTweet thisAlerts:
@Troy_IIIauthorJan 30.2015 — Microsoft IE gave us a [B]stable sort[/B], others didn't!

That's where "The Superiority of Microsoft Internet Explorer JavaScript Sort function" lies. Am I speaking English or Tarzan? ? lol
Copy linkTweet thisAlerts:
@LesshardtoofindJan 30.2015 — Interesting.

What are the advantages of using this over well defined sorting algorithyms?

Considering its only supported in one platform wouldn't it be more effective for a coder to write a sorting function based on a well defined Quicksort that would apply to all browsers rather than just IE.


I do agree that it is nice to have the functionality in IE, but as with most tools that are only supported in one browser type won't most coders stay away from its use?

Also what is the sort performance. Is there a point where the sort becomes too large?

I'm interested to hear your opinions on this.

As for honest opinion on "The Superiority of Microsoft Internet Explorer" that statement by itself I will always have a problem agreeing with due to a long track record with their inability to control buffer overflows ect. The league of legends patcher runs on IE and I find often times if I have two programs open using active scripts in IE and then open my patcher the patcher won't work. Even Facebook + Gmail moans at me all the time and gives random inability to redraw the screen. These are things I don't see occur on Firefox, and Chrome.
Copy linkTweet thisAlerts:
@Troy_IIIauthorJan 30.2015 — Interesting.

What are the advantages of using this over well defined sorting algorithyms?
[/quote]

Well, what well defined sorting algos? Could you name one.

Considering its only supported in one platform wouldn't it be more effective for a coder to write a sorting function based on a well defined Quicksort that would apply to all browsers rather than just IE.

[/QUOTE]


Do you have any of these well defined Quicksort syntaxes that we can test on other browsers and see if they do the job stable enough, so to be useful in real-world data sorting conditions?

Can you please point us to a certain example.


Also what is the sort performance. Is there a point where the sort becomes too large?

I'm interested to hear your opinions on this.[/QUOTE]


Well, same as with any other data processing functions, large amounts of data will tend to take their time. Although this algo is the fastest possible from js standing point, the rest will depend on js engine and DOM parsing. In most common sizes of data sorting reordering and displaying /redrawing (the sorted) results, (using this approach) the effect is practically instant.



I do agree that it is nice to have the functionality in IE, but as with most tools that are only supported in one browser type won't most coders stay away from its use?
[/quote]

They all support [Array].sort([ method]), but their sort is "unstable" meaning unreliable, therefore in most of the cases useless, which is not the case with Explorer.

As for honest opinion on "The Superiority of Microsoft Internet Explorer" that statement by itself I will always have a problem agreeing with due to a long track record with their inability to control buffer overflows ect. The league of legends patcher runs on IE and I find often times if I have two programs open using active scripts in IE and then open my patcher the patcher won't work. Even Facebook + Gmail moans at me all the time and gives random inability to redraw the screen. These are things I don't see occur on Firefox, and Chrome.[/QUOTE]

Well, IE is not to blame for deploying specific or wrong code, deliberately written to stress out IE, -The web was since forever full (of this kind) of free examples and copy-paste scripts that js newbies will not shy from using and later complain, or tutorials which deliberately teach specifically incompatible ways of expression that would either not work at all or give unexpected results on IE engine. I blame it on ignorance of the coder and the lack of neutral code and examples from IE pro's too. jQuery is also written in the most inefficient way targeting and exploiting different ways of Explorer.

One of the most evil ways of not even attacking shortfalls of IE, but exactly the opposite was for instance this simple html junk of code </div>. Knowing that IE is one of them browsers which does top-to-bottom and bottom-to-top scanning before rendering, using old superior approach of error-correction algorithms in making your received stream of data over faulty modems and other stream data loss events, readable error-free, structurally and visually useful and on top of it all available.

Now if that division tag canceling-instruction was really meant to be there, IE would have 99% of the times successfully place the opening tag where it was meant too, -but since this one was deliberately placed where it doesn't belong and was never even meant to exist in the code, IE will most likely fail to find a correct place for its opening, which will later cause all sorts of JavaScript errors etc. ?

Now, you really have to be a low evil creature for this kind of undermining, but yet again - this was the only way to fool the kids.
Copy linkTweet thisAlerts:
@LesshardtoofindJan 30.2015 — Well, what well defined sorting algos? Could you name one.[/QUOTE]

I don't mean already established javascript ones, but I just mean already established universal algorythms (I know you know these bubblesort, insertionsort, quicksort ect) and then just apply them to any variable within the code. Profiling is not my strong point so I don't claim to know the answer to if one sort would universally perform well. I was merely asking.

Do you have any of these well defined Quicksort syntaxes that we can test on other browsers and see if they do the job stable enough, so to be useful in real-world data sorting conditions?

Can you please point us to a certain example. [/QUOTE]


As for coming up with personal examples I am finishing up a module at the moment but may have time to code up a javascript sort tomorrow that does the same as yours. A quick google search on different types shows some already existing methods though if you are truly interested in testing.

Example JS Quicksort https://www.google.com/?gws_rd=ssl#q=javascript+quicksort+array

Very good list of Sorting Types and advantages vs disadvantages of the algorithm on a core level: http://homepages.ihug.co.nz/~aurora76/Malc/

They all support [Array].sort([ method]), but their sort is "unstable" meaning unreliable, therefore in most of the cases useless, which is not the case with Explorer.[/QUOTE]


Interesting I was not aware of this. I wonder what IE added to their execution that achieved a better consistency.


I do believe that not understanding how to play nice with IE is the fault of the Coder. I have spent many years learning from lots of different sources, and while I don't know anywhere near what I should about it I have gotten to a functional level of JavaScript coding. (I'm sure I fall into your bad coder category for not understanding IE, but theres only one way to learn.)

I will say from the perspective of a hobby coder just learning from tutorials and books it is hard to tell when starting out if you are being taught bad code since the author usually won't tell you so. I have recently started trying to use as much original documentation as I can, and then if possible get my code reviewed by someone more experienced before publishing/ going live with it (especially if its for a client).

As for other APIs/Frameworks/Chrome setting IE up to fail, by intentionally breaking IE that is very interesting. I can definitely see the advantage of google trying to break IE when they get the chance so as to get more clients on chrome. You'd think a major competitor like Microsoft would just countermeasure with a patch, but its probably hard to keep up with all the **** competitors are throwing at you when you are that big.
Copy linkTweet thisAlerts:
@jedaisoulJan 31.2015 — 
Well, what well defined sorting algos? Could you name one.
[/QUOTE]

See [url=http://www.nczonline.net/blog/2012/11/27/computer-science-in-javascript-quicksort/]here[/url]...


They all support [Array].sort([ method]), but their sort is "unstable" meaning unreliable, therefore in most of the cases useless, which is not the case with Explorer.
[/QUOTE]

As I understand it, in this context, "unstable" means "not preserving the natural order". So why do you say that an "unstable" sort is "unreliable, therefore in most of the cases useless"?

Quicksorts can be stable or unstable depending upon the implementation, but I do not see that the stability of IE's implementation (if that is indeed the case) outweighs its comparative inefficiency (if that is indeed the case)?
Copy linkTweet thisAlerts:
@LesshardtoofindJan 31.2015 — Quicksorts can be stable or unstable depending upon the implementation, but I do not see that the stability of IE's implementation (if that is indeed the case) outweighs its comparative inefficiency (if that is indeed the case)? [/QUOTE]

That is kind of what I was trying to get at. I don't see the advantage of using a method stuck to one browser when you could program your own version of a Quicksort, InsertionSort, BubbleSort, ect that would accomplish the same thing across all browsers.

Ultimately when I wrote a Sudoku Game in JavaScript I found that its overall ability to handle large datasets is lacking so when it boils down to any large datasets I'd still probably think the sort was more well deserved to be done serverside.
Copy linkTweet thisAlerts:
@Troy_IIIauthorJan 31.2015 — that's where you are not only wrong but also in denial.

No further comments are worthy until you defer. Or are welcome back to reality.
Copy linkTweet thisAlerts:
@LesshardtoofindFeb 01.2015 — that's where you are not only wrong but also in denial.

No further comments are worthy until you defer. Or are welcome back to reality. [/QUOTE]


You continually crack me up with your everyone is out to get Microsoft mentality.

I assume the denial was directed not at me, because I have denied nothing merely inquired. Though I never did receive a well posed response to those inquiries. May leave one wondering where the denial truly lies good sir.
Copy linkTweet thisAlerts:
@jedaisoulFeb 01.2015 — that's where you are not only wrong but also in denial.

No further comments are worthy until you defer. Or are welcome back to reality.[/QUOTE]


Who was this comment addressed to? Defer to what? In denial of what? Please answer the arguments put to you courteously and without ad hominem, or you may be excluded.
Copy linkTweet thisAlerts:
@Troy_IIIauthorFeb 01.2015 — chrome vs explorer, in javascript array sorting

https://www.youtube.com/watch?v=T-uZLWLLftM

or shuffling vs sorting.

Have more fun. ?
Copy linkTweet thisAlerts:
@sumantoFeb 01.2015 — Nice

[IMG]http://rockbullet.tk/31/o.png[/IMG]
×

Success!

Help @Troy_III 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.19,
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,
)...