How To Sort Just Part Of A Huge List Using .NET

Mar 8, 2010

In .NET, the Generics Lists have a sort function that accepts IComparer or Comparison. I'd like to sort just part of a list. Hopefully I can specify the start index, count of elements to sort, and a lambda function. It looks like you can only use lambda functions to do this if you're sorting the entire list. Is that right or did I miss something?

View 4 Replies


ADVERTISEMENT

Save A Huge List Of Inventory Items?

Aug 31, 2009

I am programing a basic P.O.S. (Point of Sale) system, ad am looking for the best way to save Inventory objects. The object contains a few Singles and Strings (Such as barcode, name, price...ect). Assuming the user could possibly input thousands of such items, what is the best way to store and handle these?

My first, and simplest thought, is to add each inventory Item to an ArrayList, then once the user saves, or closes, the ArrayList prints each object to a text file, then when the program opens it reads the text file to re-populate the Array list. However, this seems very un-efficient (I assume). Would it be better to use an excell file or a Database (I know almost nothing about databases, but I can learn), or something completely different?

View 4 Replies

.net - Reduce The Lag Of Loading A Huge List Of Text Lines To A Listbox?

May 27, 2009

I am using file.readalllines to read the file into a string, then using listbox.items.addrange and splitting by vbcrlf to insert the items. Is there a way to reduce the lag it causes for loading huge lists?

View 6 Replies

.net - Use List.Sort And Comparision(of T) To Sort Descending/Ascending?

Jul 5, 2011

I have a MyObject; myObjects as List(Of MyObject) and a delegate Comparison(Of MyObject) that uses a lot of comparison functions (ByA, ByB, ByC etc) Ã la:

Shared Function CompareMyObjectsByName(x As MyObject, y As MyObject) As Integer
Return x.Name.CompareTo(y.Name)
End Function

[Code].....

View 2 Replies

Sort Files In Directory Based On Part Of File Name?

Jan 27, 2012

How to sort the files in the directory based on the part of the file name?[code]...

View 2 Replies

List(Of T).Sort - Sort The List By Year

Jul 10, 2011

I have a List(Of T) storing a list of Custom classes called Advertisement. Each advertisement contains 3 properties, Year, Make and Model. I need to sort the list By Year, then by Make and then by Model. I have a property in the Advertisement class called Vehicle which returns a formatted string with the Year Make Model like 2007 Toyota Tacoma and ive been sorting on that but its not working how I thought it would. Basically I want to sort the list by Year (decending; lowest year first) then sort by the Make and Model (in alphabetical order) Is that even possible? Here is the code ive been using.

[Code]...

View 8 Replies

VS 2005 Sort List Of Objects By Child List Order?

Jul 20, 2011

I'm having a bit of a 'brain doner' moment here

I have a list of Objects. Each of these Objects contains a list of other Objects (pseudo code) :-

Private Structure Object1
dim Name as string
dim ListOfObject2 as List(Of Object2)

[Code]....

I need to sort the list of Object1 by the Value in Object2. I have a comparison class which sorts Object2 by its Value nicely.

View 13 Replies

.net - Sort Generic List Based Upon A Different List?

Oct 29, 2010

What would be the fastest way to sort a list that contains a list of objects, based upon another list? An example follows:Say I have multiple lists of employees. Each individual list has a common property value, say "Department". So I have a list of employees, in one list they all have the department string value of "Sales". In another list all the objects have a department value of "Finance". These lists of employees are then contained in a list which holds them all.

I have a second list, which should drives the sort order of the employee lists. The second list simply contains a list of strings like, "Finance", "Sales", "IT" and so on. I'd like my lists of customers to be sorted in the order of "Finance", "Sales", etc.I'm using VB.NET in .NET 2.0

View 1 Replies

Copy Part Of A List?

Sep 18, 2009

I have a data structure like this :- myvar.mylistdata where mylistdata is of type list (of list (othertype)).

I want to then move the elements of a specified sub list to another list of list var like tmpvar.mylistdata, so i have been trying code like this[code]...

View 5 Replies

Create A Sub Menu That List Part Numbers?

Oct 27, 2010

I would like to create a sub menu that list part numbers that are gathered from a xml file. I am having trouble with creating the sub routines for the part numbers menus because it can change.

Private Sub mnuP1Layers_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim BFFile as string
My.Computer.FileSystem.MoveFile(BFFile, "C:ExchangePrintedBFFile")

View 3 Replies

How To Sort List Of Datarow

Aug 5, 2011

i have a list of datarows. each row is having mutiple columns like userid,date,flag,etc.i want to sort the based on date. how can i do that ?

my code is:

Dim
listOfRows As
New List(Of
DataRow)()

[code]....

i want to sort the listOfRows in ascending order of date which is a column in a row?

View 4 Replies

Sort A List Of Word?

Sep 30, 2011

i wrote the following code to sort a list of word:

Public Class Sort_DT
Public Sub Words(ByVal index As Short, ByVal Incoming(,,) As String, ByVal Level As Integer)

[code]....

when words sorted, application used over 300 MB of memory;

View 14 Replies

Sort An Array List?

May 27, 2009

I'm trying to sort an arraylist the code is below.

the value.sort() is returning the following error - Failed to compare two elements in the array. At least one object must implement IComparable."[code]...

View 2 Replies

Sort Items In A List Box?

Apr 6, 2010

I am trying to sort items in a list box. It sorts all the numbers but one and i can't figure out why. I will post my code below. The last number is on the bottom when it is entered into the list box every time regardless of its size.

Dim sortformat As String = "{0,-10}{1,12}"
Dim w As String
Dim y As String
For x = 0 To 7

[code]....

View 3 Replies

.net - Sort Generic List On Two Or More Values?

May 15, 2009

We have a generic List(Of Product) that must be sorted on two or more properties of the Product class.

The product class has the properties "Popular" numeric (asc), "Clicked" numeric (desc), "Name" string (asc). In order of naming the properties we want the list to sort.

How can it be sort with an lamba statement? If have found to sort the list based on one property.

View 4 Replies

.net - Sort List Where Object IsNot Nothing?

Mar 2, 2011

I am trying to sort a list of classes, and I need the classes with a subclass that isnot nothing first in the list. I thought the following would work but it doesnt.ListOfClasses.Sort(Function(x, y) If(x.SubClass IsNot Nothing, 1, 0)

View 3 Replies

How To Sort Items In List View

Apr 5, 2012

i used the sorting method at msdn but it isnt nice. it sorts in string format like 1,11,12,2,21,23,3,31,32 etc. is there any other sorting method.

View 3 Replies

How To Sort Multiple Column Of A List

Apr 15, 2009

I have a class for example:

Public Class Employee
Private mName As String
Private mSalary As Double

[Code].....

View 6 Replies

List.Sort Not Quite Working With Strings?

Feb 13, 2011

This is my first time posting here although I have been lurking for quite some time. I'm stuck with a problem I have seen before and never solved: I have a long list (~23,000) of alphanumeric strings that I'm reading into a List(of String) from a text file, and then sorting. When I iterate through the list after sorting, it appears to be correctly sorted EXCEPT that the element that was originally at the beginning of the list is now at the end (and it should be somewhere in the middle after the sort)Here is a sample input:

PRE1-PRE2_00015648
PRE1-PRE2_00015649
PRE1-PRE2_00015650

[code].....

View 5 Replies

Sort A List (Of String) Alphanumerically?

Apr 26, 2012

I have looked, unsuccessfully, for how to sort a list of strings alpha numerically. The .Sort() method sorts it like so:

abc,abc1,abc11,abc12,abc2,abc21,abc22

I don't want it sorted that way, I want it sorted like so:

abc,abc1,abc2,abc11,abc12,abc21,abc22

View 1 Replies

Sort A List Based On Numeric Value?

Mar 13, 2009

sort a list based on numeric value of a list struct element:- For example... private structure myparamsdim level as integerdim otherend structure...level_list as new list(of myparams)..dim mydata as myparamsmydata.level=5level_list.add(mydata)mydata.level=9level_list.add(mydata)mydata.level=2level_list.add(mydata)'how do I get a list sorted by myparams.level?additionally, do I have to resort every time I add an entry or can I add in a way that it add's by .level?

View 1 Replies

Sort A List Like IRC Chat Rooms Do With The @'s And +'s?

May 31, 2009

I'M currently working on a custom listview class, but I never have been able to figure out how to use the Icomparer for what I need to do.Basically I'M trying to sort a list like IRC chat rooms do, with the @'s and +'s.So say this is how I want the list to look.

@Adam
@Mike
@Tom
+Amy

[code]....

Each item has a Rank property, and if rank is 1 it's @, 2 it's +, other it's just normal.

View 14 Replies

Sort An Object In A List On A Non-unique Value?

Dec 17, 2011

I'm trying to categorize articles by stored keywords. I have a list of keywords for a category, and I want an article to get assigned a category that has the most keyword count.

For Each keyword As String In category.Keywords
category.tempCount += Regex.Matches(article.Item("title").InnerXml, Regex.Escape(keyword)).Count

[code].....

View 2 Replies

Sort List Box In Decensing Order?

Mar 23, 2011

How to Sort List Box in decensing order? both alphabetic and numeric.

View 1 Replies

Sort List Of Class Using Id Property?

Oct 8, 2010

I have a class called Questions. This Questions has properties QuestionID and QuestionAnswer. My list of Questions has QuestionID like 2, 3,4, 15, 12, 24,22,,,, etc.I need to sort this List of Questions Object based on QuestionID and store in another Questions object.

View 2 Replies

Sorting - List.sort Not Working?

Apr 3, 2009

I have a slightly odd problem that I think is most likely due to an act of foolishness on my part, but for the life of me I (and other members of my team) can't see it.I have an object that contains a generic list property which I would like to sort. I have written a comparer class to do this for me and I am calling it in the following way:baseObject.ListOfThings.Sort(new ThingComparer()I have debugged into my compare function and it is returning the right values.However After the sort call, the list remains unchanged. Have I missed something obvious, or is there something else I need to do.EDIT: Yes I was being a fool, and the property returning a list was recreating it from scratch each time it was accessed

View 4 Replies

VS 2010 How To 'sort' A List Variable

Feb 19, 2011

I have this

Public strDBData As New List(Of SearchDatabases)
Public Structure SearchDatabases
Public strName as String

[code].....

If you need to know what i'm doing this it it:I'm parsing a webpage that lists information such as; Name, Site URL, How many members etc.And thats fine, but i want to put the names in a listbox, and then when the user clicks a name in the listbox it displays the other data about that name such as the site URL and how many members they have.This is easy to do but i have made my listbox sorted so the names display alphabetically, so then my strDBData index's don't line up correctly, to fix this i need to sort the

View 6 Replies

Alphabetically Sort A Generic List (Of String) In .NET?

Dec 1, 2009

I've created and populated a generic list of strings like this:

Dim MyList As New List(Of String)
MyList.Add("Beta")
MyList.Add("Echo")

[code]....

Now I want to order it.

View 1 Replies

Alphabetically Sort Letters Shown In List?

Jan 20, 2010

I am working on the old hangman game. I am up to a part were I have to use a sort button to alphabetically sort the letters already guessed that are showing in the list.

I have found this code:
Array.Sort(strLettersGuessed)
lblGuessed.Text = ""
For i = 0 To strLettersGuessed.Length - 1
lblGuessed.Text = lblGuessed.Text + strLettersGuessed(i) + ", "
[Code] .....

The problem I am having is where the flow chart asks us "is the letter at counter < the letter at counter -1? In my above code I am trying to answer this with this line:
If intCounter < strLettersGuessed.Length - 1 Then

I have tried about 50 different things in place of intCounter as well as strLettersGuessed.Length -1 and nothing seems to work. Sometimes I get an error stating can't be infinite, etc or I get no error at all but the sort button doesn't work.

View 12 Replies

C# - Order List By Arbitrary Sort Expression?

Mar 2, 2011

I have a generic list, like this:
System.Collections.Generic.List<Question> myquestions = new System.Collections.Generic.List<Question>();

And I have a paging example, using a LINQ table acquried from database, doing this for paging:
var questions = context.Questions
.OrderBy(sidx + " " + sord)
.Skip(pageIndex * pageSize)
.Take(pageSize);

Right now, for paging my populated from code list, I have:
var questionss = myquestions
.OrderBy(x => x.Id)
.Skip(pageIndex * pageSize)
.Take(pageSize);

And what I want is being able to order "myquestions" by a string as in the above example. Is that possible?

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved