Link to home
Start Free TrialLog in
Avatar of bounty457
bounty457

asked on

How can i sort a List to get the newest .mp3 Files

Hello,
i'am using in C# a List to save the filenames from one directory.
The Last 17 numbers are the timestamp.

This is the content of myList:

241_3_Rock__20141015210003828.mp3
241_3_Rock__20141016210001752.mp3
241_3_Rock__20141017210001782.mp3
241_3_Rock__20141018210001368.mp3
330_1___20141015210007187.mp3
330_1___20141016210003971.mp3
330_1___20141017210002719.mp3
330_1___20141018210001884.mp3
400_1___20141015210007187.mp3
400_1___20141016210003971.mp3
400_1___20141017210002719.mp3
400_1___20141018210001884.mp3
330_1__600207_20141017084127436.mp3
400_1__500107_20141017084127436.mp3


I need the newest Files with beginning:
241_3_Rock
330_
400_

this should be the result:
241_3_Rock__20141018210001368.mp3
330_1___20141018210001884.mp3
400_1___20141018210001884.mp3

this should be ignored:
330_1__******
400_1__******

result ignored:
330_1__600207_20141017084127436.mp3
400_1__500107_20141017084127436.mp3

Do you have any ideas for this?
Very welcome with source Example.
Thank you very much in advance,
Kind regards
Bounty
Avatar of Fernando Soto
Fernando Soto
Flag of United States of America image

Your question states, "How can i sort a List to get the newest .mp3 Files". So from what I get from the question you want to get a sub-group of the files with the newest ones on top ordered by date from the filename and not just sort the list?

We need some more information. For example how do you determine which files are ignored in the list?

In your question you state that, "this should be the result:"

241_3_Rock__20141018210001368.mp3
330_1___20141018210001884.mp3
400_1___20141018210001884.mp3

But from what I can tell this is the sort order by date;

330_1___20141018210001884.mp3
400_1___20141018210001884.mp3
241_3_Rock__20141018210001368.mp3

Can you please explain. Thank you
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of bounty457
bounty457

ASKER

Thank you very much,

it works fine.

Kind regrads
I've requested that this question be closed as follows:

Accepted answer: 0 points for bounty457's comment #a40494527

for the following reason:

Very Good
Hi Bounty457.

You seem to have accepted your own answer as the answer, when I think you should have been accepting another expert's answer. You haven't responded to either Expert's answer but your last comment indicates that it works.

I've objected to your closing of the question so that you can assign points accordingly.

Thanks

Chris