OK, it looks like your array comes out to be:
20050331,20050214,20050405,20050101
Normally what ya need to do is to compare as dates, but looks like the
comparison it wil work as numbers/text due to the way the date is saved - y,m,d
and that 0's are included.
Here is the current order:
1 2005 03 31
2 2005 02 14
3 2005 04 05
4 2005 01 01
And this is the order you want:
1 2005 01 01 (4)
2 2005 02 14 (2)
3 2005 03 31 (1)
4 2005 04 05 (3)
str = "20050331,20050214,20050405,20050101"
arr = split(str,",")
For i = 0 To UBound(arr) - 1
For j = i To UBound(arr)
if arr(i) > arr(j) Then
intTempStore = arr(i)
arr(i) = arr(j)
arr(j) = intTempStore
End if
Next
Next
For i = 0 to UBOUND(arr)
str = arr(i)
y = left(str,4)
m = mid(str,5,2)
d = right(str,2)
str = y&"/"&m&"/"&d
str = formatdatetime(str,1)
response.write "<a href=""backup_"& arr(i) & """>Backup for "& str &"<br>"
Next
HTH
dcase14 <[EMAIL PROTECTED]> wrote:
Hi Michael
The files have all been named renamed during the backup process to be
<filename>_<dateofbackup>. e.g.
backup_20050331
backup_20050214
backup_20050405
backup_20050101
I want them sorted in reverse chronological order (newest file first)
Here is the code for listing the files and putting them into an array
Where MyBuDir = (filepath to directory on server)
<%
'=========================
'Begin Get Info -> String Loop
'Get info from FSO
Set MyFS = CreateObject("Scripting.FileSystemObject")
Set f = MyFS.GetFolder(server.mappath(MyBuDir))
Set fc = f.Files
For Each MyFile in fc
MyTrim = Right (MyFile, 8)
'Put info into String
MyString = Mystring & "," & cStr(MyTrim)
Next
'Response.write "My string: " & MyString & "<BR>"
'=========================
'Split String into Array
MyArray = Split(MyString,",")
'=========================
%>
Thanks in advance
--- In [email protected], Michael Brinkley
<[EMAIL PROTECTED]> wrote:
> Just give us an example list of files and then the list of how you
want them sorted.
>
> Also include the code you use to extract the list of files.
>
> Mike
>
> "Driver, Nicholas" <[EMAIL PROTECTED]> wrote:
> Hi everybody
>
> After my hassles last week trying t get a list of files from an FSO
into an
> array, I've set up a bubblesort (copied code form 4guysfromrolla)
but can't
> work out how to sort in descending order. Here is the code:
>
> '=========================
> 'Sort Array
>
> Sub SingleSorter( byRef MyArray )
> Dim row, j
> Dim StartingKeyValue, NewKeyValue, swap_pos
>
> For row = 0 To UBound( MyArray ) - 1
> 'Take a snapshot of the first element
> 'in the array because if there is a
> 'smaller value elsewhere in the array
> 'we'll need to do a swap.
> StartingKeyValue = MyArray ( row )
> NewKeyValue = MyArray ( row )
> swap_pos = row
>
> For j = row + 1 to UBound( MyArray )
> 'Start inner loop.
> If arrArray ( j ) < NewKeyValue Then
> 'This is now the lowest number -
> 'remember it's position.
> swap_pos = j
> NewKeyValue = MyArray ( j )
> End If
> Next
>
> If swap_pos <> row Then
> 'If we get here then we are about to do a swap
> 'within the array.
> MyArray ( swap_pos ) = StartingKeyValue
> MyArray ( row ) = NewKeyValue
> End If
> Next
> End Sub
>
> SingleSorter MyArray
> '=========================
>
> Any suggestions would be great. I'd actually prefer some hints and
pointers
> to help me learn than a complete solution 'out of the box' so to speak.
>
> cheers
> Nick
>
>
--------------------------------------------------------------------------------
> This E-Mail is intended only for the addressee. Its use is limited
to that
> intended by the author at the time and it is not to be distributed
without the
> author's consent. Unless otherwise stated, the State of Queensland
accepts no
> liability for the contents of this E-Mail except where subsequently
confirmed in
> writing. The opinions expressed in this E-Mail are those of the
author and do
> not necessarily represent the views of the State of Queensland. This
E-Mail is
> confidential and may be subject to a claim of legal privilege.
>
> If you have received this E-Mail in error, please notify the author
> and delete this message immediately.
>
--------------------------------------------------------------------------------
> !DEPTSTAMP1!
>
>
> ---------------------------------
> Yahoo! Groups Links
>
> To visit your group on the web, go to:
> http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/
>
> To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
>
> Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
>
>
>
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Small Business - Try our new resources site!
>
> [Non-text portions of this message have been removed]
---------------------------------
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/
To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
Yahoo! Messenger
Show us what our next emoticon should look like. Join the fun.
[Non-text portions of this message have been removed]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/