|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Sorted array suggestionstake - any suggestions appreciated. For example, using mp3's, If I collect: 1) song title 2) file name 3) producer 4) artist 5) bit rate and the user wants to see one list sorted by artist and another by title what's the general concensus for the structure to use. I realize a database would be most efficient but the program I'm working with has none, and I'm not sure I want to create one given the 'fluidity' of a users 'collection' of song. As I understand it array.sort expects a one dimensional array. I don't see how an array of a structure could be used to sort by various 'columns'. Hope this is sufficiently clear. Suggestions?? Thanks //al
Show quote
Hide quote
> I need to create a collection of data and I'm not sure what approach to I suggest you use a ListView control. You can have columns for your data, > take - any suggestions appreciated. > > For example, using mp3's, If I collect: > 1) song title > 2) file name > 3) producer > 4) artist > 5) bit rate > and the user wants to see one list sorted by artist and another by title > what's the general concensus for the structure to use. I realize a > database would be most efficient but the program I'm working with has none, > and I'm not sure I want to create one given the 'fluidity' of a users > 'collection' of song. > > As I understand it array.sort expects a one dimensional array. I don't see > how an array of a structure could be used to sort by various 'columns'. and you can arrange to sort the display on any of the columns. You would have to write some code to populate the ListView with data (maybe from one or more external files). If you have a structure containing all the mp3 info, you could create a
class that implements the IComparer interface and in the CompareTo method, you would provide the logic to compare two of your structure variables. You could add a property to the class to indicate which field to sort on. Then when you call the Array.Sort, you pass in an instance of your comparer class. I second Chris' suggestion. It might be a little complicated to
implement, but once done, it will work the best, and give high performance while sorting is performed. Personally I have found a huge performance difference between sorting data using a control's built-in sort method and sorting data by using an IComparer. Regards, Cerebrus. On 7 Apr 2006 06:27:30 -0700, Chris Dunaway wrote:
> If you have a structure containing all the mp3 info, you could create a Thank you both, one is over my head at the moment and the other I'm not> class that implements the IComparer interface and in the CompareTo > method, you would provide the logic to compare two of your structure > variables. > > You could add a property to the class to indicate which field to sort > on. Then when you call the Array.Sort, you pass in an instance of your > comparer class. sure about. Ended up just stuffing them as concatenated strings into an array, calling sort and now off to figuring out how to 'print' them to a richtextbox. Holding onto your information as time passes and my expertise, hopefully, improves. //al
Timespan perplexing, please help with brain freeze.
Threading 101 Can the read() function in VB.NET start reading from somewhere else than 0 Frustrations with RTF format. DataGridView - Property DataPropertyName Reg expression How to declare char string pointer in VB? KeyDown for non Active windows? Playing card suits, vb.net? Shared Variable Question VB.NET 2003 |
|||||||||||||||||||||||