sorting

XSLT sort subelement followup

Similar to the previous subelement sort, but I have a few extra layers of nodes. I can't figure out a simple extension to the previous answer that works. http://stackoverflow.com/questions/572854/how-to-sort-a-subelement-of-xml-with-xslt The simplified input example: <Iteration> <Iteration_query-ID>NODE_10008</Iteration_query-ID> ...

Sorting a gridview when databinding a collection or list of objects

I am attemping to have my gridview be: bound by a List in code-behind. I am using my own custom BOL. no datasource object on the html page sortable on each column that I choose. The SortExpressions are all set correctly. The resulting error message: The GridView 'myGridView' fired event Sorting which wasn't handled. How can I have...

What's a better way to sort by day date?

I have an Array of Events and I want to divide them into a 2-dimensional Array based on event_date (which returns a Time object). But I want it to be by the day part of the date. Here's what I have so far: def divide_events_by_day(events) # Sort, so we can start with the first day. events = events.sort { |x,y| x.event_date <=> y.eve...

Java: reverse sorting without keeping the order

Update: In fact, the only acceptable solution for this problem would be sorting the array ascending and then reversing it. Let S be the following sequence of events: Event | Time A | 0:00 B | 0:01 C | 0:01 D | 0:02 I have a simple Comparator to sort S, which sorts the elements according to the time value. public int ...

How to sort on the Value of an member of a List<> within a parent List<>

I have a List sort question. I am using c# 3.0 and a generic List structure like this: public class myObject { public int ID { get; set; } public List<mySetting> setting { get; set; } } public class mySetting { public int ID { get; set; } public string Name { get; set; } public string Value { get; set; } // sort o...

Multiple sortable lists with jquery

I am building a todo list application for one of my projects and I am creating multiple todo lists dynamically from the database and each todo list will have multiple todo items. The items will be constrained to their own list and will not be able to be connected to another list. I've done a single sortable list in jquery before, but ...

Sort array of items using OrderBy<>

I have an array of items and I would like to sort on one of their properties. I can access the items property using "item.Fields["FieldName"].Value" the property is returned as a string but I can cast it to an int. I had a look at OrderBy<> but I have no idea of how to use it. ...

GridView ASP.NET Sorting

I have an ASP.NET GridView that just won't sort! I'm sure that I am missing something pretty obvious. Page.aspx <asp:GridView ID="TimeAwayGridView" runat="server" AutoGenerateSelectButton="False" AutoGenerateEditButton="False" AutoGenerateDeleteButton="False" AllowPaging="False" AllowSorting="True" CssClass="gridview" OnSortin...

Firebird determine if a string is all numbers

I have a VARCHAR field in a Firebird 2.0 table that can contain alphanumeric characters. I need to sort data on this field, sorting all values that contain only numbers as numbers, and sort all other values as 0. For example, if I have four values, "1", "2", "10", "string", I need to sort it as "string", "1", "2", "10". Default sort with...

How do I sort an object within an array?

I have searched and found a couple of solutions on this site, that didn't work for me. My case is that I perform a XPath search (contains function) in the XML, and lists the results. I want those results listed alphabetically. The results are laying in an array, and looks like this: Array ( [0] => SimpleXMLElement Object ( ...

User interface for sorting a table by multiple columns

I need a user interface that allows users to sort a table according to multiple columns (e.g. sort by color and then price within color, or alternatively price and then color within price). The only such interface I'm familiar with is the dialogue box found in Excel under data > sort, but this is rather clunky and does not yield itself t...

Why does C# let me compile sort code when it doesnt know how to sort

I thought it was odd that C# let me call sort on my class and not specify a way to sort them nor write a compare overload. When i ran this code this error popped up List<MyClass> myClassArray= new List<MyClass>(); //myClassArray.add(...); myClassArray.Sort(); An unhandled exception of type 'System.InvalidOperationException' occurred in...

How would I sort through an array of structs?

I have a struct containing song data: public struct uLib { public string Path; public string Artist; public string Title; public string Album; public string Length; } My library consists of an array of this uLib. How would I sort this array by say Artist? Is there a native sort functio...

Separating groups into nearly-equal stacks

I have a list of documents and I want to display them grouped by the first letter of their name on a web-page, over three columns. In short, something like this: A | C | E A | D | F B | D | F B | D | F | D | An important difference from say, the Windows Explorer view style is that I want letters to stay with each other. No breaking...

Display vs. Search vs. Sort strings in a database

Let's say I've got a database full of music artists. Consider the following artists: The Beatles - "The" is officially part of the name, but we don't want to sort it with the "T"s if we are alphabetizing. We can't easily store it as "Beatles, The" because then we can't search for it properly. Beyoncé - We need to allow the user to be...

Strategy for detecting an object in JTable row?

Here's the thing: a sortable JTable backed by JTableModel with an array of objects that populate rows (one object = one row). Need to delete rows. Without sorting, deleting an object is simple: get selected row index, delete array object under the same index. With sorting, though, row indexes mess up in a sense that they no longer match...

How to implement a natural sort algorithm in c++?

I'm sorting strings that are comprised of text and numbers. I want the sort to sort the number parts as numbers, not alphanumeric. For example I want: abc1def, ..., abc9def, abc10def instead of: abc10def, abc1def, ..., abc9def Does anyone know an algorithm for this (in particular in c++) Thanks ...

How to keep a file's format if you use the uniq command (in shell)?

In order to use the uniq command, you have to sort your file first. But in the file I have, the order of the information is important, thus how can I keep the original format of the file but still get rid of duplicate content? ...

[PHP] Sort a multi-dimensional array

Hi! I need to sort a multi-dimensional array which represents filesystem structure: Array ( [dir1] => Array ( [dir2] => Array ( [dir3] => Array ( [dir4] => Array ( ...

Sort objects using predefined list of sorted values

I was wondering what would be the fastest way to sort an array of object in the same order as a different array. Here is an example in C#: class MyClass { public MyClass(int value) { this.value = value; } int value; public int Value { get { return value; } set { this.value = value; } ...