sorting

save xml object so that elements are in sorted order in saved xml file

Hi , I am saving a xml document object and it is saved in a xml file as shown below . <author name="tom" book="Fun-II"/> <author name="jack" book="Live-I"/> <author name="pete" book="Code-I"/> <author name="jack" book="Live-II"/> <author name="pete" book="Code-II"/> <author name="tom" book="Fun-I"/> instead i want to sort the conten...

ASP.NET GridView sorting on method data

Hi, I'm binding a GridView to a domain model object, this domain model object has a method for working out a formatted value to display on the grid. I'd like to use this method for my display value, which is fine, but I'd also like to be able to sort on the value returned by that method. My sort expression can only take in a property/...

string categorization strategies

I'm the one-man dev team on a fledgling military history website. One aspect of the site is a catalog of ~1,200 individual battles, including the nations & formations (regiments, divisions, etc) which took part. The formation information (as well as the other battle info) was manually imported from a series of books by a 10-man voluntee...

Strange things appear on running the program

Hey! I'm fixing a program but I'm facing a problem and I cant really realize what's the wrong on the code. I would appreciate any help. I didnt post all the code...but i think with this part you can get an idea of it. With the following function enter() I wanna add user commands' datas to a list. eg. user give the command: "en james b...

Wordpress - Force most recent posts first

I want to use the plugin WP Smart Sort to sort my posts alphabetically, except I need the most recent posted first on the home page. The relevant existing code for the home page is below. Is there something I can add to it to force it to include the recent posts and go by date rather than by the alphabetical order I want everywhere else?...

Table Column Resizing/Drag 'n' Dropping in jQuery

I'm looking for a way to implement both resizing and drag 'n' drop for columns (not rows) within a predefined table using jQuery. I've done a bit of Googling and haven't really found anything that fits the bill as many require you to essentially reconstruct your table using jQuery. I simply want to plug this functionality in, not have my...

sorting char* arrays

Hi! I have a datastructure struct record { char cont[bufferSize]; record *next; }; When I add new records to this structure, I want them to be sorted alphabetically. I made this function, that adds record in the right place (by alphabet) in the linked list: record *start=NULL, *p, *x; void recAdd(char*temp) { p = new...

Stable separation for two classes of elements in an array

Consider the following problem. We are given an array of elements belonging to one two classes: either red or blue. We have to rearrange the elements of the array so that all blue elements come first (and all red elements follow). The rearrangement must be done is stable fashion, meaning that the relative order of blue elements must be ...

Best tree/heap data structure for fixed set of nodes with changing values + need top 20 values?

I'm writing something like a game in C++ where I have a database table containing the current score for each user. I want to read that table into memory at the start of the game, quickly change each user's score while the game is being played in response to what each user does, and then when the game ends write the current scores back to...

sort a struct array by attribute value

Ive got a task in C to sort a struct by using qsort struct user { enum SEX{m, f} sex; char name[32]; char phonenr[32]; }; typedef struct user User; the users will be stored in a array of 25 elements but how do i sort them on something like name ? ...

SSRS 2008 Interactive Sorting in Sub-Report not working as expected

I have a (parent) report that has a list. The details group of this list contains one sub-report. So basically if the list has 10 records (rows) the sub-report is executed 10 times. The problem seems to be with interactive sorting in the Sub-Report. It has 4 columns with interactive sorting enabled. When I run the parent report and try ...

How to sort a list by the 2nd tuple element in python and C#

I had a list of tuples where every tuple consists of two integers and I wanted to sort by the 2nd integer. After looking in the python help I got this: sorted(myList, key=lambda x: x[1]) which is great. My question is, is there an equally succinct way of doing this in C# (the language I have to work in)? I know the obvious answer invo...

PHP Sort a multidimensional array by element containing date

I have an array such as: Array ( [0] => Array ( [id] => 2 [type] => comment [text] => hey [datetime] => 2010-05-15 11:29:45 ) [1] => Array ( [id] => 3 [type] => status [text] => oi [datetime] => 2010-05-26 15:59:53 ) [2] => Array ( [id] => 4 ...

Dojo: programatic sort in enhanced data grid

How do I create a programmatic sort in EDG? I have used the doh robot, but I want to do it directly, I've noticed the sort methods use an e event, is there anyway I can generate or obtain this e event? ...

How do I sort a list of python Django objects?

In Django, I have a model object in a list. [object, object, object] Each object has ".name" which is the title of the thing. How do I sort alphabetically by this title? This doesn't work: catlist.sort(key=lambda x.name: x.name.lower()) ...

PowerShell: Read text, regex sort, write output to file and formatting

I am a Powershell novice and have run into a challenge in reading, sorting, and outputting a csv file. The input csv has no headers, the data is as follows: 05/25/2010,18:48:33,Stop,a1usak,10.128.212.212 05/25/2010,18:48:36,Start,q2uhal,10.136.198.231 05/25/2010,18:48:09,Stop,s0upxb,10.136.198.231 I use the following piping construct ...

How do I maintain rows when sorting a matrix in MATLAB?

I have a 2-by-3 matrix, and I want to sort it according to the first column. Here's an example: data will change to --> new data 11 33 10 22 22 44 11 33 10 22 22 44 I have this code for sorting a matrix A but it doesn't work well: sort(A,1,'ascend'); ...

Solr sort by function

Hi, I need to sort query results by the output of some function which takes "score" and couple other fields as an input (50% of the total score comes from similarity score and 50% comes from document's popularity). Is there a way to do this without having to install "Sort by Function" patch? Thanks! ...

Making ListView in a WinForm Sortable?

In Windows' file explorer, you can sort ListViews by clicking on the column header to sort by. Is it possible to add this type of functionality to a ListView in a WinForm? If so, how can this be done? Thanks! :D ...

access following entry in a form_for, and switch a value between two entry of my DB

I am displaying a list of articles. I sort my articles by the param order and I want when displaying the list of article to be able to "move" them up or down. In php I do everything with a for browsing my array of results and inside the for I go to the next index to find where I am in the list, and with which other article I must swap m...