Bug 139753 - File sorting should be case-insensitive
File sorting should be case-insensitive
Status: STARTED
Product: platform
Classification: Unclassified
Component: Data Systems
8.0
All All
: P3 with 13 votes (vote)
: 8.2
Assigned To: Jaroslav Havlin
issues@platform
: API_REVIEW_FAST, NETFIX
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2008-07-11 16:41 UTC by malfunction84
Modified: 2016-10-19 13:12 UTC (History)
8 users (show)

See Also:
Issue Type: DEFECT
:


Attachments
screenshot (13.38 KB, image/gif)
2008-09-02 15:39 UTC, malfunction84
Details
Proposed patch (10.98 KB, patch)
2016-08-26 00:27 UTC, markiewb
Details | Diff
Patch in action (29.90 KB, image/png)
2016-08-26 00:27 UTC, markiewb
Details
Proposed patch v2 (23.71 KB, patch)
2016-08-31 21:46 UTC, markiewb
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description malfunction84 2008-07-11 16:41:55 UTC
Product Version: NetBeans IDE 6.1 (Build 200804211638)
Java: 1.6.0_06; Java HotSpot(TM) Client VM 10.0-b22
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)

I believe this was just introduced by NB6.1 Patch2.

The "Projects" and "Files" windows now display file lists which have been sorted with case sensitivity.  Files with
capital letters appear before files with lowercase letters.

An example from the "Projects" window:

- My Test Project
  - Web Pages
    + META-INF
    + WEB-INF
    + images
    + includes
      Test.jsp
      error.jsp
      index.jsp
  - Source Packages
    - <default package>
        JSONMapping.properties
        hibernate.cfg.xml
Comment 1 Peter Pis 2008-07-30 08:40:06 UTC
Reassigning to "projects".
Comment 2 Milan Kubec 2008-09-02 12:29:03 UTC
I don't see any difference before the patch and after the patch, it works still the same.
Comment 3 malfunction84 2008-09-02 15:39:14 UTC
Created attachment 68880 [details]
screenshot
Comment 4 malfunction84 2008-09-02 15:46:19 UTC
The screenshot is from NB 6.5 beta.

Notice how "WEB-INF" appears before "images."  Also, "Dataexporter.properties" appears before
"alpha.ExceptionHandler.properties."  It appears that the file-sorting algorithm is case-sensitive.

What patch are you referring to?
Comment 5 Milan Kubec 2008-09-03 07:26:38 UTC
> What patch are you referring to?

In your original post you wrote: "I believe this was just introduced by NB6.1 Patch2." 

So I compared NetBeans 6.1 before and after the patch and found out that there were no changes in sorting.

Sorting works still the same way, there were no changes so this issue is not a DEFECT, but rather an ENHANCEMENT to
allow to sort files in Explorer views without case sensitivity.
Comment 6 malfunction84 2008-09-03 15:11:57 UTC
Right, my mistake.  I guess I just never noticed it before the patch.

If case-sensitive file sorting is intended behavior, I agree that it is an ENHANCEMENT and not a DEFECT.  The file
sorting in NetBeans is not consistent with file sorting performed by Windows.  Perhaps NetBeans' file sorting should
only be case-insensitive for file systems which are case-insensitive.
Comment 7 malfunction84 2009-10-01 00:02:03 UTC
Changing Platform/OS.
Comment 8 malfunction84 2010-03-04 15:05:59 UTC
Adding "on Windows" to summary.
Comment 9 dhinged 2012-09-19 21:43:59 UTC
It doesn't appear to be sorting consistently by the Linux file sort either, as I am on Ubuntu, which sorts by case-insensitive letter, while NetBeans sorts by case-sensitive letter. 

Linux dev01 2.6.32-42-server #95-Ubuntu SMP Wed Jul 25 16:10:49 UTC 2012 x86_64 GNU/Linux

- Project
  - Source Files
    + Test
    + build
    + library
    + site
    Makefile
    build.xml
    version.txt

ls -l through putty:

drwxr-xr-x  3 xxx xxx 4096 2012-09-07 13:21 build
-rw-r--r--  1 xxx xxx 4393 2012-09-07 13:22 build.xml
drwxr-xr-x  8 xxx xxx 4096 2012-09-07 13:22 library
-rw-r--r--  1 xxx xxx 4740 2012-09-07 13:22 Makefile
drwxr-xr-x 16 xxx xxx 4096 2012-09-11 11:05 site
drwxr-xr-x  6 xxx xxx 4096 2012-09-07 13:21 Test
-rw-r--r--  1 xxx xxx    5 2012-09-07 13:22 version.txt

I realize that Ubuntu is sorting all files and directories together alphabetically, but it's still case-insensitive. I have no option in NetBeans to sort files and directories separately as case-insensitive.
Comment 10 skydiver 2013-05-25 14:18:22 UTC
You got my vote. I have a project in which most files begin with a Captial letter, thus any files that begin with lowercase, get pushed all the way down.
This leads to frustration as files that are supposed to be there are mysteriously gone.
Comment 11 cnasr 2014-01-24 14:45:06 UTC
I am having the exact same problem in both OS X and Ubuntu Linux. This should be fixed across the board, not just on Windows.
Comment 12 AaronN322 2014-02-07 13:54:54 UTC
This is soo annoying. It sometimes takes me forever to find a file when I think I know what the name is, but this NetBeans defect sorts it unlike anything else, ever:

I look for customeritemlookup and it appears not to even be there until I ralize that lower case letters have a lower priority than uppercase AND symbols. It is just ridiculous.


CustomerInvoiceController.php
CustomerInvoiceDetailController.php
CustomerInvoiceHeaderController.php
CustomerItemCompareController.php
CustomerItemMarginsController.php
CustomerProfileController.php
CustomerProfileItemsController.php
CustomerProfileSummaryController.php
Customer_item_activityController.php
Customer_item_groupController.php
Customer_xrefController.php
CustomeritemlookupController.php
CustomersController.php
CutReportController.php



It is even worse in my /include/ folder with hundreds of files named class_whatever.php and I look for a class, but find out it is way at the bottom of the list because someone saved it with a lowercase letter.
Comment 13 AaronN322 2014-02-07 14:02:07 UTC
tl;dr - Uppercase letters (capitals or majuscules) and lowercase letters (minuscules) have equal arrangement value.






Also, for those who say it is not a defect, take a look at this document, Guidelines for
Alphabetical Arrangement
of Letters and Sorting of
Numerals and Other
Symbols, 

by The National Information Standards Organization 

which is accredited by the American National Standards Institute (ANSI) to develop and maintain technical standards for libraries, information services, and
publishers.

http://www.niso.org/publications/tr/tr03.pdf

page 2:
The basic order of characters should be in the following sequence:
spaces
symbols other than numerals, letters, and punctuation marks
numerals (0 through 9)
letters (A through Z)

3.6 Letters (A through Z)
Roman alphabet letters should be arranged according to their order in the English alphabet.
Uppercase letters (capitals or majuscules) and lowercase letters (minuscules) have equal arrangement value. Different typefaces (italic, boldface, blackletter, etc.) do not affect the arrangement of letters. Examples are shown in Figure 1. See also Section 6.4.
Comment 14 MerceanCoconut 2014-04-24 13:33:28 UTC
Extremely annoying, this bug is still present in version 8.0.
Comment 15 stiffuser 2014-06-17 20:12:05 UTC
The case-sensitive sort should be fixed in the "projects" view as well as the "file" view

Updating bug description/versions to indicate that it's still present.
Comment 16 Tomas Stupka 2014-07-09 10:48:19 UTC
(In reply to AaronN322 from comment #12)
> This is soo annoying. It sometimes takes me forever to find a file when I
> think I know what the name is, 
maybe as a possible workaround - select the view and type whatever substring from the files name ...
Comment 17 boarmanc 2015-03-03 00:05:50 UTC
Still happening in 8.02, in both the Project explorer and the File explorer.

BTW - I noticed that if I right-click on a folder in the projects view, there is a Sort Mode option in the Properties dialog. I can change this to sort by 'unsorted', 'modification time', 'file size', 'extension', 'class', as well as 'By Name' and 'By Name (Packages First). The latter appears to be the default. Both of these Name options still result in the reported problem of upper case appearing before lower case. However, 'By Modification Time' is useful because the more recently change files (the ones I am working on) appear at the top of the list, regardless of case.
Comment 18 sproger1 2015-07-15 17:05:19 UTC
At a minimum: 

Allow the user community to develop plugin(s) that enable additional sort modes so that those of us that are unhappy with the current behavior can simply install a plugin to get the behavior we want.

Changes needed to allow this are:

1) Make FolderComparator.java a public class OR do not cast DataFolder.SortMode objects to FolderComparator objects without first checking that it is assignable...

2) Allow DataFolder.setMode() method to support not only support the hardcoded 'public static final SortMode' fields in the DataFolder class, but instead support any class that extends SortMode. The current design is poorly implemented.

See bug: https://netbeans.org/bugzilla/show_bug.cgi?id=242226

Some of us want/expect case-insensitive sorting, and some also want sorting that takes numbers in the names of files into account when sorting by name. If the lower level classes weren't made final and hardcoded the way they are now, then it would be quite easy to extend the existing behavior via plugins (as it should be).
Comment 19 markiewb 2016-08-26 00:27:07 UTC
Created attachment 161773 [details]
Proposed patch

Please have a look at this patch.

* It introduces case-insensitive by default.
* It introduces a system property to set the default ordering of DataFolder's children.
Comment 20 markiewb 2016-08-26 00:27:37 UTC
Created attachment 161774 [details]
Patch in action
Comment 21 Jaroslav Tulach 2016-08-27 04:39:49 UTC
Y01 The API defines new systemproperty
https://netbeans.org/bugzilla/attachment.cgi?id=161773&action=diff#openide.loaders/arch.xml_sec1
but I haven't found a test that would verify behavior of the property. Try to use System.setProperty(...), run the test method, set System.setProperty(...) back.

Y02 The [changes to use compareIgnoreCase](https://netbeans.org/bugzilla/attachment.cgi?id=161773&action=diff#openide.loaders/src/org/openide/loaders/FolderComparator.java_sec1) are in my opinion incompatible change (I am surprised no test fails, but probably this code was written sooner than we started to write tests). Moreover I don't think the change to "ignore case" makes sense on Unix. We have case sensitive filesystems. Rather than changing this I'd suggest to introduce yet another sorting mode.

PS: long time ago I had to add [http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-masterfs/overview-summary.html](http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-masterfs/overview-summary.html) - that could be be re-used for choosing whether to ignore case or not. Or better - the behavior of case sensitive vs. case insensitive should match what masterfs is internally doing.
Comment 22 markiewb 2016-08-31 21:46:25 UTC
Created attachment 161853 [details]
Proposed patch v2

(In reply to Jaroslav Tulach from comment #21)
> Y01 The API defines new systemproperty
> https://netbeans.org/bugzilla/attachment.cgi?id=161773&action=diff#openide.
> loaders/arch.xml_sec1
> but I haven't found a test that would verify behavior of the property. Try
> to use System.setProperty(...), run the test method, set
> System.setProperty(...) back.
> 

@Y01: I removed the whole introduction of a new system property to setup the default FolderComparator. It is not neccessary to fulfill the request of case-insensitive sortings. I was tricked by https://netbeans.org/bugzilla/show_bug.cgi?id=139753#c18

> Y02 The [changes to use
> compareIgnoreCase](https://netbeans.org/bugzilla/attachment.
> cgi?id=161773&action=diff#openide.loaders/src/org/openide/loaders/
> FolderComparator.java_sec1) are in my opinion incompatible change (I am
> surprised no test fails, but probably this code was written sooner than we
> started to write tests). Moreover I don't think the change to "ignore case"
> makes sense on Unix. We have case sensitive filesystems. Rather than
> changing this I'd suggest to introduce yet another sorting mode.
> 
> PS: long time ago I had to add
> [http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-masterfs/overview-
> summary.html](http://bits.netbeans.org/dev/javadoc/org-netbeans-modules-
> masterfs/overview-summary.html) - that could be be re-used for choosing
> whether to ignore case or not. Or better - the behavior of case sensitive
> vs. case insensitive should match what masterfs is internally doing.


@Y01: 
A linux user could also mount a case-insensitive FAT32 partion, so it makes no sense to rely on the OS system type to switch the case-sensitivity mode.

Also there is no API in the JDK yet to find out, if the filesystem is case-sensitive or not.
http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4034654

But in my new patch I simply use the system property "org.netbeans.modules.masterfs.case" which you introduced in 7.2 especially for such cases. https://netbeans.org/bugzilla/show_bug.cgi?id=198946

This time it is backward-compatible. Users can enable the new behaviour by setting the flag. For the next version I will create a new task-issue to enable this flag by default for the windows user. My idea is to update the windows installer, so that it generates etc\netbeans.conf with "-J-Dorg.netbeans.modules.masterfs.case=insensitive" in "netbeans_default_options"

Yarda, please have a look again! Thank you.
Comment 23 Jaroslav Tulach 2016-09-01 07:19:07 UTC
Fine with me. Possibly remove the @author tag on your new test files.


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo