Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Unified Diff: ui/file_manager/file_manager/common/js/util.js

Issue 479503002: Files.app: Not use URL in sorting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed the comment Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/directory_contents.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/file_manager/common/js/util.js
diff --git a/ui/file_manager/file_manager/common/js/util.js b/ui/file_manager/file_manager/common/js/util.js
index 78a952ad6be0c209503f02548f443e5106bbe3db..25af53434638b685ac5d95b681ed20b2a6b886a7 100644
--- a/ui/file_manager/file_manager/common/js/util.js
+++ b/ui/file_manager/file_manager/common/js/util.js
@@ -1006,6 +1006,34 @@ util.isSameFileSystem = function(fileSystem1, fileSystem2) {
};
/**
+ * Collator for sorting.
+ * @type {Intl.Collator}
+ */
+util.collator = new Intl.Collator([], {usage: 'sort',
+ numeric: true,
+ sensitivity: 'base'});
+
+/**
+ * Compare by name. The 2 entries must be in same directory.
+ * @param {Entry} entry1 First entry.
+ * @param {Entry} entry2 Second entry.
+ * @return {number} Compare result.
+ */
+util.compareName = function(entry1, entry2) {
+ return util.collator.compare(entry1.name, entry2.name);
+};
+
+/**
+ * Compare by path.
+ * @param {Entry} entry1 First entry.
+ * @param {Entry} entry2 Second entry.
+ * @return {number} Compare result.
+ */
+util.comparePath = function(entry1, entry2) {
+ return util.collator.compare(entry1.fullPath, entry2.fullPath);
+};
+
+/**
* Checks if the child entry is a descendant of another entry. If the entries
* point to the same file or directory, then returns false.
*
« no previous file with comments | « no previous file | ui/file_manager/file_manager/foreground/js/directory_contents.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698