[vwnc] Windows Explorer filename sorting behavior

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[vwnc] Windows Explorer filename sorting behavior

Charles Adams
Has anyone ever managed to create a sorting algorithm for filenames that emulates Windows Explorer?
 
For instance, given the following filename examples,
 
VW sorts as: 
 
a1a.txt 
a1a01a.txt 
a1a09a.txt.txt 
a1a100a.txt 
a1a100a1a.txt 
a1a2a.txt 
Windows Explorer sorts as:
 
a1a01a.txt 
a1a2a.txt 
a1a09a.txt.txt 
a1a100a1a.txt 
a1a100a.txt 
a1a.txt 
 
First of all, I'm not convinced its worth the effort. Unix uses pure alpha sorting. AFAIK, Windows Explorer follows a path unique in the computing world.
 
Second, as a sort block, the solution might not be very efficient. In fact, it could be really difficult to manage without caching.
 
 
Charlie
Adventa

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Windows Explorer filename sorting behavior

Andres Valloud-6
Looks like alpha sort, but giving $. a lot of weight so it goes past letters and digits... I have a feeling it should be possible to (ab)use some sorting collation into providing what you need.
 
Andres.


From: [hidden email] [mailto:[hidden email]] On Behalf Of Charles Adams
Sent: Monday, November 24, 2008 11:01 AM
To: [hidden email]
Subject: [vwnc] Windows Explorer filename sorting behavior

Has anyone ever managed to create a sorting algorithm for filenames that emulates Windows Explorer?
 
For instance, given the following filename examples,
 
VW sorts as: 
 
a1a.txt 
a1a01a.txt 
a1a09a.txt.txt 
a1a100a.txt 
a1a100a1a.txt 
a1a2a.txt 
Windows Explorer sorts as:
 
a1a01a.txt 
a1a2a.txt 
a1a09a.txt.txt 
a1a100a1a.txt 
a1a100a.txt 
a1a.txt 
 
First of all, I'm not convinced its worth the effort. Unix uses pure alpha sorting. AFAIK, Windows Explorer follows a path unique in the computing world.
 
Second, as a sort block, the solution might not be very efficient. In fact, it could be really difficult to manage without caching.
 
 
Charlie
Adventa

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Windows Explorer filename sorting behavior

Charles Adams
Right. To be clear: I don't want to do the work. Its tedious and probably ill-advised. But if I could borrow it... :)
 
Charlie
 
---- Original Message -----
Sent: Monday, November 24, 2008 1:11 PM
Subject: Re: [vwnc] Windows Explorer filename sorting behavior

Looks like alpha sort, but giving $. a lot of weight so it goes past letters and digits... I have a feeling it should be possible to (ab)use some sorting collation into providing what you need.
 
Andres.


From: [hidden email] [mailto:[hidden email]] On Behalf Of Charles Adams
Sent: Monday, November 24, 2008 11:01 AM
To: [hidden email]
Subject: [vwnc] Windows Explorer filename sorting behavior

Has anyone ever managed to create a sorting algorithm for filenames that emulates Windows Explorer?
 
For instance, given the following filename examples,
 
VW sorts as: 
 
a1a.txt 
a1a01a.txt 
a1a09a.txt.txt 
a1a100a.txt 
a1a100a1a.txt 
a1a2a.txt 
Windows Explorer sorts as:
 
a1a01a.txt 
a1a2a.txt 
a1a09a.txt.txt 
a1a100a1a.txt 
a1a100a.txt 
a1a.txt 
 
First of all, I'm not convinced its worth the effort. Unix uses pure alpha sorting. AFAIK, Windows Explorer follows a path unique in the computing world.
 
Second, as a sort block, the solution might not be very efficient. In fact, it could be really difficult to manage without caching.
 
 
Charlie
Adventa


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Windows Explorer filename sorting behavior

Boris Popov, DeepCove Labs (SNN)
Charlie,

You may want to keep in mind that different versions Windows have
different sort algorithms, so matching your application with a platform
might be even trickier.

http://support.microsoft.com/default.aspx?kbid=319827

-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5
http://tinyurl.com/r7uw4

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message header.
Unless otherwise indicated, it contains information that is private and
confidential. If you have received it in error, please notify the sender
and delete the entire message including any attachments.

Thank you.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Charles Adams
Sent: Monday, November 24, 2008 11:16 AM
To: [hidden email]
Subject: Re: [vwnc] Windows Explorer filename sorting behavior

Right. To be clear: I don't want to do the work. Its tedious and
probably ill-advised. But if I could borrow it... :)
 
Charlie
 
---- Original Message -----

        From: Valloud, Andres <mailto:[hidden email]>  
        To: [hidden email]
        Sent: Monday, November 24, 2008 1:11 PM
        Subject: Re: [vwnc] Windows Explorer filename sorting behavior

        Looks like alpha sort, but giving $. a lot of weight so it goes
past letters and digits... I have a feeling it should be possible to
(ab)use some sorting collation into providing what you need.
         
        Andres.

________________________________

        From: [hidden email] [mailto:[hidden email]]
On Behalf Of Charles Adams
        Sent: Monday, November 24, 2008 11:01 AM
        To: [hidden email]
        Subject: [vwnc] Windows Explorer filename sorting behavior
       
       
        Has anyone ever managed to create a sorting algorithm for
filenames that emulates Windows Explorer?
         
        For instance, given the following filename examples,
         
        VW sorts as:
         
        a1a.txt
        a1a01a.txt
        a1a09a.txt.txt
        a1a100a.txt
        a1a100a1a.txt
        a1a2a.txt
       
        Windows Explorer sorts as:
         
       
        a1a01a.txt
        a1a2a.txt
        a1a09a.txt.txt
        a1a100a1a.txt
        a1a100a.txt
       
        a1a.txt
         
        First of all, I'm not convinced its worth the effort. Unix uses
pure alpha sorting. AFAIK, Windows Explorer follows a path unique in the
computing world.
         
        Second, as a sort block, the solution might not be very
efficient. In fact, it could be really difficult to manage without
caching.
         
         
        Charlie
        Adventa

       
________________________________


       

        _______________________________________________
        vwnc mailing list
        [hidden email]
        http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
       


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Windows Explorer filename sorting behavior

Charles Adams
Hmm, that was unexpected.

In the spirit of full disclosure: Filenames were just an easy, illuminating
example of the problem before me. In practice, my customer wants me to sort
lists of strings of any origin following these rules, or something close
anyway. Just so '10' does not sort ahead of '9'. I can see where this leads
and I really don't like it. That's why I thought I'd try to vulture
someone's work.

Charlie



----- Original Message -----
From: "Boris Popov" <[hidden email]>
To: "Charles Adams" <[hidden email]>; <[hidden email]>
Sent: Monday, November 24, 2008 1:25 PM
Subject: RE: [vwnc] Windows Explorer filename sorting behavior


> Charlie,
>
> You may want to keep in mind that different versions Windows have
> different sort algorithms, so matching your application with a platform
> might be even trickier.
>
> http://support.microsoft.com/default.aspx?kbid=319827
>
> -Boris
>
> --
> +1.604.689.0322
> DeepCove Labs Ltd.
> 4th floor 595 Howe Street
> Vancouver, Canada V6C 2T5
> http://tinyurl.com/r7uw4
>
> [hidden email]
>
> CONFIDENTIALITY NOTICE
>
> This email is intended only for the persons named in the message header.
> Unless otherwise indicated, it contains information that is private and
> confidential. If you have received it in error, please notify the sender
> and delete the entire message including any attachments.
>
> Thank you.
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of Charles Adams
> Sent: Monday, November 24, 2008 11:16 AM
> To: [hidden email]
> Subject: Re: [vwnc] Windows Explorer filename sorting behavior
>
> Right. To be clear: I don't want to do the work. Its tedious and
> probably ill-advised. But if I could borrow it... :)
>
> Charlie
>
> ---- Original Message -----
>
> From: Valloud, Andres <mailto:[hidden email]>
> To: [hidden email]
> Sent: Monday, November 24, 2008 1:11 PM
> Subject: Re: [vwnc] Windows Explorer filename sorting behavior
>
> Looks like alpha sort, but giving $. a lot of weight so it goes
> past letters and digits... I have a feeling it should be possible to
> (ab)use some sorting collation into providing what you need.
>
> Andres.
>
> ________________________________
>
> From: [hidden email] [mailto:[hidden email]]
> On Behalf Of Charles Adams
> Sent: Monday, November 24, 2008 11:01 AM
> To: [hidden email]
> Subject: [vwnc] Windows Explorer filename sorting behavior
>
>
> Has anyone ever managed to create a sorting algorithm for
> filenames that emulates Windows Explorer?
>
> For instance, given the following filename examples,
>
> VW sorts as:
>
> a1a.txt
> a1a01a.txt
> a1a09a.txt.txt
> a1a100a.txt
> a1a100a1a.txt
> a1a2a.txt
>
> Windows Explorer sorts as:
>
>
> a1a01a.txt
> a1a2a.txt
> a1a09a.txt.txt
> a1a100a1a.txt
> a1a100a.txt
>
> a1a.txt
>
> First of all, I'm not convinced its worth the effort. Unix uses
> pure alpha sorting. AFAIK, Windows Explorer follows a path unique in the
> computing world.
>
> Second, as a sort block, the solution might not be very
> efficient. In fact, it could be really difficult to manage without
> caching.
>
>
> Charlie
> Adventa
>
>
> ________________________________
>
>
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>
>
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Windows Explorer filename sorting behavior

Boris Popov, DeepCove Labs (SNN)
You could do something like this to extract numerical values and build a
sort block that compares collections of pieces accordingly,

#('Ie4_01' 'Ie4_128' 'Ie5' 'Ie6' 'Ie401sp2' 'Ie501sp2')
        collect:
                [:ea |
                | pieces |
                pieces := ea piecesCutWhere: [:each :next | (each
isDigit and: [next isDigit not]) or: [each isDigit not and: [next
isDigit]]].
                pieces := pieces collect: [:piece | piece first isDigit
ifTrue: [piece asNumber] ifFalse: [piece]]]

1:  OrderedCollection ('Ie' 4 '_' 1)
2:  OrderedCollection ('Ie' 4 '_' 128)
3:  OrderedCollection ('Ie' 5)
4:  OrderedCollection ('Ie' 6)
5:  OrderedCollection ('Ie' 401 'sp' 2)
6:  OrderedCollection ('Ie' 501 'sp' 2)

-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5
http://tinyurl.com/r7uw4

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message header.
Unless otherwise indicated, it contains information that is private and
confidential. If you have received it in error, please notify the sender
and delete the entire message including any attachments.

Thank you.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Charles Adams
Sent: Monday, November 24, 2008 11:43 AM
To: [hidden email]
Subject: Re: [vwnc] Windows Explorer filename sorting behavior

Hmm, that was unexpected.

In the spirit of full disclosure: Filenames were just an easy,
illuminating
example of the problem before me. In practice, my customer wants me to
sort
lists of strings of any origin following these rules, or something close

anyway. Just so '10' does not sort ahead of '9'. I can see where this
leads
and I really don't like it. That's why I thought I'd try to vulture
someone's work.

Charlie



----- Original Message -----
From: "Boris Popov" <[hidden email]>
To: "Charles Adams" <[hidden email]>; <[hidden email]>
Sent: Monday, November 24, 2008 1:25 PM
Subject: RE: [vwnc] Windows Explorer filename sorting behavior


> Charlie,
>
> You may want to keep in mind that different versions Windows have
> different sort algorithms, so matching your application with a
platform

> might be even trickier.
>
> http://support.microsoft.com/default.aspx?kbid=319827
>
> -Boris
>
> --
> +1.604.689.0322
> DeepCove Labs Ltd.
> 4th floor 595 Howe Street
> Vancouver, Canada V6C 2T5
> http://tinyurl.com/r7uw4
>
> [hidden email]
>
> CONFIDENTIALITY NOTICE
>
> This email is intended only for the persons named in the message
header.
> Unless otherwise indicated, it contains information that is private
and
> confidential. If you have received it in error, please notify the
sender

> and delete the entire message including any attachments.
>
> Thank you.
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of Charles Adams
> Sent: Monday, November 24, 2008 11:16 AM
> To: [hidden email]
> Subject: Re: [vwnc] Windows Explorer filename sorting behavior
>
> Right. To be clear: I don't want to do the work. Its tedious and
> probably ill-advised. But if I could borrow it... :)
>
> Charlie
>
> ---- Original Message -----
>
> From: Valloud, Andres <mailto:[hidden email]>
> To: [hidden email]
> Sent: Monday, November 24, 2008 1:11 PM
> Subject: Re: [vwnc] Windows Explorer filename sorting behavior
>
> Looks like alpha sort, but giving $. a lot of weight so it goes
> past letters and digits... I have a feeling it should be possible to
> (ab)use some sorting collation into providing what you need.
>
> Andres.
>
> ________________________________
>
> From: [hidden email] [mailto:[hidden email]]
> On Behalf Of Charles Adams
> Sent: Monday, November 24, 2008 11:01 AM
> To: [hidden email]
> Subject: [vwnc] Windows Explorer filename sorting behavior
>
>
> Has anyone ever managed to create a sorting algorithm for
> filenames that emulates Windows Explorer?
>
> For instance, given the following filename examples,
>
> VW sorts as:
>
> a1a.txt
> a1a01a.txt
> a1a09a.txt.txt
> a1a100a.txt
> a1a100a1a.txt
> a1a2a.txt
>
> Windows Explorer sorts as:
>
>
> a1a01a.txt
> a1a2a.txt
> a1a09a.txt.txt
> a1a100a1a.txt
> a1a100a.txt
>
> a1a.txt
>
> First of all, I'm not convinced its worth the effort. Unix uses
> pure alpha sorting. AFAIK, Windows Explorer follows a path unique in
the

> computing world.
>
> Second, as a sort block, the solution might not be very
> efficient. In fact, it could be really difficult to manage without
> caching.
>
>
> Charlie
> Adventa
>
>
> ________________________________
>
>
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>
>
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Windows Explorer filename sorting behavior

Charles Adams
That's clever. I've never seen this method before, #piecesCutWhere:. That
captures the Windows technique exactly.

Thanks...
Charlie


----- Original Message -----
From: "Boris Popov" <[hidden email]>
To: "Charles Adams" <[hidden email]>; <[hidden email]>
Sent: Monday, November 24, 2008 2:10 PM
Subject: RE: [vwnc] Windows Explorer filename sorting behavior


> You could do something like this to extract numerical values and build a
> sort block that compares collections of pieces accordingly,
>
> #('Ie4_01' 'Ie4_128' 'Ie5' 'Ie6' 'Ie401sp2' 'Ie501sp2')
> collect:
> [:ea |
> | pieces |
> pieces := ea piecesCutWhere: [:each :next | (each
> isDigit and: [next isDigit not]) or: [each isDigit not and: [next
> isDigit]]].
> pieces := pieces collect: [:piece | piece first isDigit
> ifTrue: [piece asNumber] ifFalse: [piece]]]
>
> 1:  OrderedCollection ('Ie' 4 '_' 1)
> 2:  OrderedCollection ('Ie' 4 '_' 128)
> 3:  OrderedCollection ('Ie' 5)
> 4:  OrderedCollection ('Ie' 6)
> 5:  OrderedCollection ('Ie' 401 'sp' 2)
> 6:  OrderedCollection ('Ie' 501 'sp' 2)
>
> -Boris
>
> --
> +1.604.689.0322
> DeepCove Labs Ltd.
> 4th floor 595 Howe Street
> Vancouver, Canada V6C 2T5
> http://tinyurl.com/r7uw4
>
> [hidden email]
>
> CONFIDENTIALITY NOTICE
>
> This email is intended only for the persons named in the message header.
> Unless otherwise indicated, it contains information that is private and
> confidential. If you have received it in error, please notify the sender
> and delete the entire message including any attachments.
>
> Thank you.
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of Charles Adams
> Sent: Monday, November 24, 2008 11:43 AM
> To: [hidden email]
> Subject: Re: [vwnc] Windows Explorer filename sorting behavior
>
> Hmm, that was unexpected.
>
> In the spirit of full disclosure: Filenames were just an easy,
> illuminating
> example of the problem before me. In practice, my customer wants me to
> sort
> lists of strings of any origin following these rules, or something close
>
> anyway. Just so '10' does not sort ahead of '9'. I can see where this
> leads
> and I really don't like it. That's why I thought I'd try to vulture
> someone's work.
>
> Charlie
>
>
>
> ----- Original Message -----
> From: "Boris Popov" <[hidden email]>
> To: "Charles Adams" <[hidden email]>; <[hidden email]>
> Sent: Monday, November 24, 2008 1:25 PM
> Subject: RE: [vwnc] Windows Explorer filename sorting behavior
>
>
>> Charlie,
>>
>> You may want to keep in mind that different versions Windows have
>> different sort algorithms, so matching your application with a
> platform
>> might be even trickier.
>>
>> http://support.microsoft.com/default.aspx?kbid=319827
>>
>> -Boris
>>
>> --
>> +1.604.689.0322
>> DeepCove Labs Ltd.
>> 4th floor 595 Howe Street
>> Vancouver, Canada V6C 2T5
>> http://tinyurl.com/r7uw4
>>
>> [hidden email]
>>
>> CONFIDENTIALITY NOTICE
>>
>> This email is intended only for the persons named in the message
> header.
>> Unless otherwise indicated, it contains information that is private
> and
>> confidential. If you have received it in error, please notify the
> sender
>> and delete the entire message including any attachments.
>>
>> Thank you.
>>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]] On
>> Behalf Of Charles Adams
>> Sent: Monday, November 24, 2008 11:16 AM
>> To: [hidden email]
>> Subject: Re: [vwnc] Windows Explorer filename sorting behavior
>>
>> Right. To be clear: I don't want to do the work. Its tedious and
>> probably ill-advised. But if I could borrow it... :)
>>
>> Charlie
>>
>> ---- Original Message -----
>>
>> From: Valloud, Andres <mailto:[hidden email]>
>> To: [hidden email]
>> Sent: Monday, November 24, 2008 1:11 PM
>> Subject: Re: [vwnc] Windows Explorer filename sorting behavior
>>
>> Looks like alpha sort, but giving $. a lot of weight so it goes
>> past letters and digits... I have a feeling it should be possible to
>> (ab)use some sorting collation into providing what you need.
>>
>> Andres.
>>
>> ________________________________
>>
>> From: [hidden email] [mailto:[hidden email]]
>> On Behalf Of Charles Adams
>> Sent: Monday, November 24, 2008 11:01 AM
>> To: [hidden email]
>> Subject: [vwnc] Windows Explorer filename sorting behavior
>>
>>
>> Has anyone ever managed to create a sorting algorithm for
>> filenames that emulates Windows Explorer?
>>
>> For instance, given the following filename examples,
>>
>> VW sorts as:
>>
>> a1a.txt
>> a1a01a.txt
>> a1a09a.txt.txt
>> a1a100a.txt
>> a1a100a1a.txt
>> a1a2a.txt
>>
>> Windows Explorer sorts as:
>>
>>
>> a1a01a.txt
>> a1a2a.txt
>> a1a09a.txt.txt
>> a1a100a1a.txt
>> a1a100a.txt
>>
>> a1a.txt
>>
>> First of all, I'm not convinced its worth the effort. Unix uses
>> pure alpha sorting. AFAIK, Windows Explorer follows a path unique in
> the
>> computing world.
>>
>> Second, as a sort block, the solution might not be very
>> efficient. In fact, it could be really difficult to manage without
>> caching.
>>
>>
>> Charlie
>> Adventa
>>
>>
>> ________________________________
>>
>>
>>
>>
>> _______________________________________________
>> vwnc mailing list
>> [hidden email]
>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>
>>
>>
>>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Windows Explorer filename sorting behavior

Boris Popov, DeepCove Labs (SNN)
No worries. If you come up with a sort block for those collections of
pieces, make sure to post it back here so others could make use of it if
they cared to; sounds like it might be something useful.

-Boris

--
+1.604.689.0322
DeepCove Labs Ltd.
4th floor 595 Howe Street
Vancouver, Canada V6C 2T5
http://tinyurl.com/r7uw4

[hidden email]

CONFIDENTIALITY NOTICE

This email is intended only for the persons named in the message header.
Unless otherwise indicated, it contains information that is private and
confidential. If you have received it in error, please notify the sender
and delete the entire message including any attachments.

Thank you.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On
Behalf Of Charles Adams
Sent: Monday, November 24, 2008 12:24 PM
To: [hidden email]
Subject: Re: [vwnc] Windows Explorer filename sorting behavior

That's clever. I've never seen this method before, #piecesCutWhere:.
That
captures the Windows technique exactly.

Thanks...
Charlie


----- Original Message -----
From: "Boris Popov" <[hidden email]>
To: "Charles Adams" <[hidden email]>; <[hidden email]>
Sent: Monday, November 24, 2008 2:10 PM
Subject: RE: [vwnc] Windows Explorer filename sorting behavior


> You could do something like this to extract numerical values and build
a

> sort block that compares collections of pieces accordingly,
>
> #('Ie4_01' 'Ie4_128' 'Ie5' 'Ie6' 'Ie401sp2' 'Ie501sp2')
> collect:
> [:ea |
> | pieces |
> pieces := ea piecesCutWhere: [:each :next | (each
> isDigit and: [next isDigit not]) or: [each isDigit not and: [next
> isDigit]]].
> pieces := pieces collect: [:piece | piece first isDigit
> ifTrue: [piece asNumber] ifFalse: [piece]]]
>
> 1:  OrderedCollection ('Ie' 4 '_' 1)
> 2:  OrderedCollection ('Ie' 4 '_' 128)
> 3:  OrderedCollection ('Ie' 5)
> 4:  OrderedCollection ('Ie' 6)
> 5:  OrderedCollection ('Ie' 401 'sp' 2)
> 6:  OrderedCollection ('Ie' 501 'sp' 2)
>
> -Boris
>
> --
> +1.604.689.0322
> DeepCove Labs Ltd.
> 4th floor 595 Howe Street
> Vancouver, Canada V6C 2T5
> http://tinyurl.com/r7uw4
>
> [hidden email]
>
> CONFIDENTIALITY NOTICE
>
> This email is intended only for the persons named in the message
header.
> Unless otherwise indicated, it contains information that is private
and
> confidential. If you have received it in error, please notify the
sender

> and delete the entire message including any attachments.
>
> Thank you.
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of Charles Adams
> Sent: Monday, November 24, 2008 11:43 AM
> To: [hidden email]
> Subject: Re: [vwnc] Windows Explorer filename sorting behavior
>
> Hmm, that was unexpected.
>
> In the spirit of full disclosure: Filenames were just an easy,
> illuminating
> example of the problem before me. In practice, my customer wants me to
> sort
> lists of strings of any origin following these rules, or something
close

>
> anyway. Just so '10' does not sort ahead of '9'. I can see where this
> leads
> and I really don't like it. That's why I thought I'd try to vulture
> someone's work.
>
> Charlie
>
>
>
> ----- Original Message -----
> From: "Boris Popov" <[hidden email]>
> To: "Charles Adams" <[hidden email]>; <[hidden email]>
> Sent: Monday, November 24, 2008 1:25 PM
> Subject: RE: [vwnc] Windows Explorer filename sorting behavior
>
>
>> Charlie,
>>
>> You may want to keep in mind that different versions Windows have
>> different sort algorithms, so matching your application with a
> platform
>> might be even trickier.
>>
>> http://support.microsoft.com/default.aspx?kbid=319827
>>
>> -Boris
>>
>> --
>> +1.604.689.0322
>> DeepCove Labs Ltd.
>> 4th floor 595 Howe Street
>> Vancouver, Canada V6C 2T5
>> http://tinyurl.com/r7uw4
>>
>> [hidden email]
>>
>> CONFIDENTIALITY NOTICE
>>
>> This email is intended only for the persons named in the message
> header.
>> Unless otherwise indicated, it contains information that is private
> and
>> confidential. If you have received it in error, please notify the
> sender
>> and delete the entire message including any attachments.
>>
>> Thank you.
>>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]] On
>> Behalf Of Charles Adams
>> Sent: Monday, November 24, 2008 11:16 AM
>> To: [hidden email]
>> Subject: Re: [vwnc] Windows Explorer filename sorting behavior
>>
>> Right. To be clear: I don't want to do the work. Its tedious and
>> probably ill-advised. But if I could borrow it... :)
>>
>> Charlie
>>
>> ---- Original Message -----
>>
>> From: Valloud, Andres <mailto:[hidden email]>
>> To: [hidden email]
>> Sent: Monday, November 24, 2008 1:11 PM
>> Subject: Re: [vwnc] Windows Explorer filename sorting behavior
>>
>> Looks like alpha sort, but giving $. a lot of weight so it goes
>> past letters and digits... I have a feeling it should be possible to
>> (ab)use some sorting collation into providing what you need.
>>
>> Andres.
>>
>> ________________________________
>>
>> From: [hidden email] [mailto:[hidden email]]
>> On Behalf Of Charles Adams
>> Sent: Monday, November 24, 2008 11:01 AM
>> To: [hidden email]
>> Subject: [vwnc] Windows Explorer filename sorting behavior
>>
>>
>> Has anyone ever managed to create a sorting algorithm for
>> filenames that emulates Windows Explorer?
>>
>> For instance, given the following filename examples,
>>
>> VW sorts as:
>>
>> a1a.txt
>> a1a01a.txt
>> a1a09a.txt.txt
>> a1a100a.txt
>> a1a100a1a.txt
>> a1a2a.txt
>>
>> Windows Explorer sorts as:
>>
>>
>> a1a01a.txt
>> a1a2a.txt
>> a1a09a.txt.txt
>> a1a100a1a.txt
>> a1a100a.txt
>>
>> a1a.txt
>>
>> First of all, I'm not convinced its worth the effort. Unix uses
>> pure alpha sorting. AFAIK, Windows Explorer follows a path unique in
> the
>> computing world.
>>
>> Second, as a sort block, the solution might not be very
>> efficient. In fact, it could be really difficult to manage without
>> caching.
>>
>>
>> Charlie
>> Adventa
>>
>>
>> ________________________________
>>
>>
>>
>>
>> _______________________________________________
>> vwnc mailing list
>> [hidden email]
>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>
>>
>>
>>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: [vwnc] Windows Explorer filename sorting behavior

Charles Adams
I created two methods (see below.) Its debatable where these might ought to
live. #stringSortAlphaNumeric is not likely useful to just any
SequenceableCollection -- the collection must include nothing but Strings.
Aside from that, this seems to work...for small samples anyway. I wouldn't
trust it for large (>1000) sets of Strings. Its not very efficient.

Thanks for the starter.

Charlie


--------------------
SequenceableCollection>>stringSortAlphaNumeric
 "This assumes that my elements are Strings."
 "Answer a copy of myself sorted alphabetically
 and numerically."

 | collection sortedCollection indices |
 collection := self collect: [:ea |
     | pieces |
     pieces := ea piecesCutWhere: [:each :next |
        (each isDigit and: [next isDigit not]) or: [each isDigit not and:
[next isDigit]]].
     pieces := pieces collect: [:piece |
        piece first isDigit
         ifTrue: [piece asNumber]
         ifFalse: [piece]]].
 sortedCollection := collection asSortedCollection: String
alphaNumericSortBlock.
 indices := sortedCollection collect: [:each | collection indexOf: each].
 ^indices collect: [:ndx | self at: ndx]

-------------------
String class>>alphaNumericSortBlock

 ^[:a :b | | imax i rval |
 imax := a size min: b size.
 i := 1.
 rval := nil.
 [i <= imax and: [rval isNil]]
  whileTrue: [
   (a at: i) = (b at: i)
    ifFalse: [
     ((a at: i) isString or: [(b at: i) isString])
      ifTrue: [
       (a at: i) asString < (b at: i) asString
        ifTrue: [rval := true]
        ifFalse: [
         (a at: i) asString > (b at: i) asString
          ifTrue: [rval := false]]]
      ifFalse: [
       (a at: i) < (b at: i)
        ifTrue: [rval := true]
        ifFalse: [
         (a at: i) > (b at: i)
          ifTrue: [rval := false]]]].
   i := i + 1].
 rval isNil ifTrue: [rval := a size < b size].
 rval]


----- Original Message -----
From: "Boris Popov" <[hidden email]>
To: "Charles Adams" <[hidden email]>; <[hidden email]>
Sent: Monday, November 24, 2008 2:47 PM
Subject: RE: [vwnc] Windows Explorer filename sorting behavior


> No worries. If you come up with a sort block for those collections of
> pieces, make sure to post it back here so others could make use of it if
> they cared to; sounds like it might be something useful.
>
> -Boris
>
> --
> +1.604.689.0322
> DeepCove Labs Ltd.
> 4th floor 595 Howe Street
> Vancouver, Canada V6C 2T5
> http://tinyurl.com/r7uw4
>
> [hidden email]
>
> CONFIDENTIALITY NOTICE
>
> This email is intended only for the persons named in the message header.
> Unless otherwise indicated, it contains information that is private and
> confidential. If you have received it in error, please notify the sender
> and delete the entire message including any attachments.
>
> Thank you.
>
> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of Charles Adams
> Sent: Monday, November 24, 2008 12:24 PM
> To: [hidden email]
> Subject: Re: [vwnc] Windows Explorer filename sorting behavior
>
> That's clever. I've never seen this method before, #piecesCutWhere:.
> That
> captures the Windows technique exactly.
>
> Thanks...
> Charlie
>
>
> ----- Original Message -----
> From: "Boris Popov" <[hidden email]>
> To: "Charles Adams" <[hidden email]>; <[hidden email]>
> Sent: Monday, November 24, 2008 2:10 PM
> Subject: RE: [vwnc] Windows Explorer filename sorting behavior
>
>
>> You could do something like this to extract numerical values and build
> a
>> sort block that compares collections of pieces accordingly,
>>
>> #('Ie4_01' 'Ie4_128' 'Ie5' 'Ie6' 'Ie401sp2' 'Ie501sp2')
>> collect:
>> [:ea |
>> | pieces |
>> pieces := ea piecesCutWhere: [:each :next | (each
>> isDigit and: [next isDigit not]) or: [each isDigit not and: [next
>> isDigit]]].
>> pieces := pieces collect: [:piece | piece first isDigit
>> ifTrue: [piece asNumber] ifFalse: [piece]]]
>>
>> 1:  OrderedCollection ('Ie' 4 '_' 1)
>> 2:  OrderedCollection ('Ie' 4 '_' 128)
>> 3:  OrderedCollection ('Ie' 5)
>> 4:  OrderedCollection ('Ie' 6)
>> 5:  OrderedCollection ('Ie' 401 'sp' 2)
>> 6:  OrderedCollection ('Ie' 501 'sp' 2)
>>
>> -Boris
>>
>> --
>> +1.604.689.0322
>> DeepCove Labs Ltd.
>> 4th floor 595 Howe Street
>> Vancouver, Canada V6C 2T5
>> http://tinyurl.com/r7uw4
>>
>> [hidden email]
>>
>> CONFIDENTIALITY NOTICE
>>
>> This email is intended only for the persons named in the message
> header.
>> Unless otherwise indicated, it contains information that is private
> and
>> confidential. If you have received it in error, please notify the
> sender
>> and delete the entire message including any attachments.
>>
>> Thank you.
>>
>> -----Original Message-----
>> From: [hidden email] [mailto:[hidden email]] On
>> Behalf Of Charles Adams
>> Sent: Monday, November 24, 2008 11:43 AM
>> To: [hidden email]
>> Subject: Re: [vwnc] Windows Explorer filename sorting behavior
>>
>> Hmm, that was unexpected.
>>
>> In the spirit of full disclosure: Filenames were just an easy,
>> illuminating
>> example of the problem before me. In practice, my customer wants me to
>> sort
>> lists of strings of any origin following these rules, or something
> close
>>
>> anyway. Just so '10' does not sort ahead of '9'. I can see where this
>> leads
>> and I really don't like it. That's why I thought I'd try to vulture
>> someone's work.
>>
>> Charlie
>>
>>
>>
>> ----- Original Message -----
>> From: "Boris Popov" <[hidden email]>
>> To: "Charles Adams" <[hidden email]>; <[hidden email]>
>> Sent: Monday, November 24, 2008 1:25 PM
>> Subject: RE: [vwnc] Windows Explorer filename sorting behavior
>>
>>
>>> Charlie,
>>>
>>> You may want to keep in mind that different versions Windows have
>>> different sort algorithms, so matching your application with a
>> platform
>>> might be even trickier.
>>>
>>> http://support.microsoft.com/default.aspx?kbid=319827
>>>
>>> -Boris
>>>
>>> --
>>> +1.604.689.0322
>>> DeepCove Labs Ltd.
>>> 4th floor 595 Howe Street
>>> Vancouver, Canada V6C 2T5
>>> http://tinyurl.com/r7uw4
>>>
>>> [hidden email]
>>>
>>> CONFIDENTIALITY NOTICE
>>>
>>> This email is intended only for the persons named in the message
>> header.
>>> Unless otherwise indicated, it contains information that is private
>> and
>>> confidential. If you have received it in error, please notify the
>> sender
>>> and delete the entire message including any attachments.
>>>
>>> Thank you.
>>>
>>> -----Original Message-----
>>> From: [hidden email] [mailto:[hidden email]] On
>>> Behalf Of Charles Adams
>>> Sent: Monday, November 24, 2008 11:16 AM
>>> To: [hidden email]
>>> Subject: Re: [vwnc] Windows Explorer filename sorting behavior
>>>
>>> Right. To be clear: I don't want to do the work. Its tedious and
>>> probably ill-advised. But if I could borrow it... :)
>>>
>>> Charlie
>>>
>>> ---- Original Message -----
>>>
>>> From: Valloud, Andres <mailto:[hidden email]>
>>> To: [hidden email]
>>> Sent: Monday, November 24, 2008 1:11 PM
>>> Subject: Re: [vwnc] Windows Explorer filename sorting behavior
>>>
>>> Looks like alpha sort, but giving $. a lot of weight so it goes
>>> past letters and digits... I have a feeling it should be possible to
>>> (ab)use some sorting collation into providing what you need.
>>>
>>> Andres.
>>>
>>> ________________________________
>>>
>>> From: [hidden email] [mailto:[hidden email]]
>>> On Behalf Of Charles Adams
>>> Sent: Monday, November 24, 2008 11:01 AM
>>> To: [hidden email]
>>> Subject: [vwnc] Windows Explorer filename sorting behavior
>>>
>>>
>>> Has anyone ever managed to create a sorting algorithm for
>>> filenames that emulates Windows Explorer?
>>>
>>> For instance, given the following filename examples,
>>>
>>> VW sorts as:
>>>
>>> a1a.txt
>>> a1a01a.txt
>>> a1a09a.txt.txt
>>> a1a100a.txt
>>> a1a100a1a.txt
>>> a1a2a.txt
>>>
>>> Windows Explorer sorts as:
>>>
>>>
>>> a1a01a.txt
>>> a1a2a.txt
>>> a1a09a.txt.txt
>>> a1a100a1a.txt
>>> a1a100a.txt
>>>
>>> a1a.txt
>>>
>>> First of all, I'm not convinced its worth the effort. Unix uses
>>> pure alpha sorting. AFAIK, Windows Explorer follows a path unique in
>> the
>>> computing world.
>>>
>>> Second, as a sort block, the solution might not be very
>>> efficient. In fact, it could be really difficult to manage without
>>> caching.
>>>
>>>
>>> Charlie
>>> Adventa
>>>
>>>
>>> ________________________________
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> vwnc mailing list
>>> [hidden email]
>>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>>
>>>
>>>
>>>
>>
>> _______________________________________________
>> vwnc mailing list
>> [hidden email]
>> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>>
>>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc