这是indexloc提供的服务,不要输入任何密码
WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Sort Properties with the Alphanum Sort
AlphaNumSort.patch (text/plain), 2.37 KB, created by
Joseph Pecoraro
on 2009-07-15 21:39:40 PDT
(
hide
)
Description:
Sort Properties with the Alphanum Sort
Filename:
MIME Type:
Creator:
Joseph Pecoraro
Created:
2009-07-15 21:39:40 PDT
Size:
2.37 KB
patch
obsolete
>Index: WebCore/ChangeLog >=================================================================== >--- WebCore/ChangeLog (revision 45964) >+++ WebCore/ChangeLog (working copy) >@@ -1,3 +1,13 @@ >+2009-07-15 Joseph Pecoraro <joepeck02@gmail.com> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Inspector: Properties Should be Sorted more Naturally >+ https://bugs.webkit.org/show_bug.cgi?id=27329 >+ >+ * inspector/front-end/utilities.js: >+ (Object.sortedProperties): added alphaNumSort sorting function >+ > 2009-07-15 Adam Langley <agl@google.com> > > No review: reverting previous change. >Index: WebCore/inspector/front-end/utilities.js >=================================================================== >--- WebCore/inspector/front-end/utilities.js (revision 45963) >+++ WebCore/inspector/front-end/utilities.js (working copy) >@@ -1,5 +1,5 @@ > /* >- * Copyright (C) 2007 Apple Inc. All rights reserved. >+ * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -96,10 +96,43 @@ Object.describe = function(obj, abbrevia > > Object.sortedProperties = function(obj) > { >+ >+ function alphaNumSort(a,b) { >+ a = a.toString(); >+ b = b.toString(); >+ if (a===b) >+ return 0; >+ >+ var diff = 0; >+ var chunk = /^\d+|^\D+/; >+ var chunka, chunkb, anum, bnum; >+ while (diff === 0) { >+ if (!a && b) >+ return -1; >+ if (!b && a) >+ return 1; >+ chunka = a.match(chunk)[0]; >+ chunkb = b.match(chunk)[0]; >+ anum = +chunka+1; // quick falsey check if its a number >+ bnum = +chunkb+1; // quick falsey check if its a number >+ if (anum && !bnum) >+ return -1; >+ if (bnum && !anum) >+ return 1; >+ if (anum && bnum) >+ diff = chunka - chunkb; >+ else if (chunka !== chunkb) >+ return (chunka<chunkb) ? -1 : 1; >+ a = a.substring(chunka.length); >+ b = b.substring(chunkb.length); >+ } >+ return diff; >+ } >+ > var properties = []; > for (var prop in obj) > properties.push(prop); >- properties.sort(); >+ properties.sort(alphaNumSort); > return properties; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
oliver
:
review-
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 27329
:
32829
|
32830
|
32832
|
32834
|
32871
|
32873
|
32879
|
33371
|
33372
|
33484