sorting

Sorting arrays of paired numbers and removing duplicates or overlaps?

How can I sort two arrays of coordinates in numerical order by the start coordinates e.g. my @starts = (100,100,200,300,400,500,525); my @ends = (150,125,250,350,450,550,550); but choose the biggest difference if there are two matching in either the starts or ends list? E.g. my @uniq_starts = (100,200,300,400,500); my @unique_ends ...

Sort In App Purchases

I'm working on a store front for my in app purchases. I have the items being loaded into an NSMutableArray within -(void)productsRequest:(SKProductsRequest *)request didReceiveResponse:(SKProductsResponse *)response however all my products start with numbers. I'd like to sort these in ascending order but whenever I use sortUsingSelecto...

perl sort temporary directory

I ran into space issues on my machine and therefore the sort command in unix failed because of lack of space in /tmp. In order to circumvent this, I decided to run sort with the -T option allowing it to use some other directory for creating temporary files. here is the perl script I have my $TMPDIR = "/home/xyz/workspace...

Custom sorting using categories and core data - is it supported by the framework?

I'm developing for iPhone iOS 4.0 and I have a list of birthday objects (date + name) stored using Core Data. I want to use the NSFetchedResultsController to retrieve this list sorted by the next birthdate date of each birthday object. For that I need to define my own logic for the sort descriptor. I tried using: [NSSortDescriptor sort...

How to keep a data-bound list reverse-sorted

I have a listbox bound to a collection. I would like the ListBox to always reverse the order of the items. This handler--hooked up to the control's load event--works for the initial load, but not thereafter. Ive tried using the SourceUpdated event but that doesnt seem to work. How do I maintain a constant active sort? MyList.Items...

Sort a list according to order defined by another list

How can I sort the elements of the list A so that they follow the ordering of another (superset) list B? Assume no duplicates. E.g. A might contain [8 2 5 1] and B might contain [5 6 9 8 7 4 1 2 3], and so I'd like to sort A to become [5 8 1 2] I'm interested in ways of doing this efficiently and with good runtime complexity. ...

Elegant way to sort an array like this

This is my array: $arr = array(-3, -4, 1, -1, 2, 4, -2, 3); I want to sort it like this: 1 2 3 4 -1 -2 -3 -4 So first there would be values greated than zero sorted from the lowest value to the highest value, then there would be negative values sorted from the highest value to the lowest value. Is there some elegant way to do this...

How do I delete the intersection of sets A and B from A without sorting in MATLAB?

Two matrices, A and B: A = [1 2 3 9 7 5 4 9 4 1 4 7] B = [1 2 3 1 4 7] All rows of matrix B are members of matrix A. I wish to delete the common rows of A and B from A without sorting. I have tried setdiff() but this sorts the output. For my particular problem (atomic coordinates in protein structures) maintaini...

Sorting all the elements in a XDocument

Hi, I have a XDocument where I'd like to sort all of the elements alphabetically. Here's a simplified version of the structure: <Config> <Server> <Id>svr1</Id> <Routing> <RoutingNodeName>route1</RoutingNodeName> <Subscription> <Id>1</Id> </Subscription> <RoutingParameters id="Routing...

Linq list sort based on another list

Hi there. I have two generic list objects, in which one contains ids and and ordering, and the other a bunch of ids with each id in the second list having an id reference to the first list, for example; public class OptionType { public int ID { get; set; } public int Ordering { get; set; } } public class...

Sorting a python array

opt=[] opt=["opt3","opt2","opt7","opt6","opt1"] for i in range(len(opt)): print opt[i] Output for the above is opt3,opt2,opt7,opt6,opt1 How to sort the above array in ascending order.. ...

How to sort a collection based on a subcollection property

I would like to sort a collection based on a subcollection property. //the subcollection public class Salary { public int SalaryId {get;set;} public int SalaryYear {get;set;} public double SalaryValue {get;set;} //this is the field we want to sort the parent collection "Person" } //the main collection public class Person { ...

Sorting scheduled events python

So I have list of events that are sort of like alarms. They're defined by their start and end time (in hours and minutes), a range of days (ie 1-3 which is sunday through wed.), and a range of months (ie 1-3, january through march). The format of that data is largely unchangeable. I need to, not necessarily sort the list, but I need to f...

How do I sort an Excel 2010 pivot table based on a subset of the data it contains?

Hi, I have an Excel 2010 pivot table that has categories and a count measure as the data. Those categories then have a date dimension nested underneath, filtered to show only the last two months. When I sort the categories, I am sorting them by the total of the count measure across both June and July, in descending order. Can anyone ...

javascript - sort by the order of a second array

Given: var a1 = [{name:'Scott'}, {name:'John'}, {name:'Albert'}]; var sortOrder = ['John', 'Scott', 'Albert']; How can I sort the first array (by property) based on the order specified in the second array. // result: [{name:'John'}, {name:'Scott'}, {name:'Albert'}] Thanks. ...

How Can I Sort A 'Version Number' Column Generically Using a SQL Server Query

I wonder if the SQL geniuses amongst us could lend me a helping hand. I have a column VersionNo in a table Versions that contains 'version number' values like VersionNo --------- 1.2.3.1 1.10.3.1 1.4.7.2 etc. I am looking to sort this, but unfortunately, when I do a standard order by, it is treated as a string, so the order comes ou...

DataGridView save filtering after reload

Hi, I have some problem with DataGridView in C#. case is: I do some update on database then I reload DataGridView with new values: myDataGridView.DataSource = myDataSet.Tables[0] Everything is ok, but recently I was asked if there is possibility to keep the same column filtering applied after reloading data? What would be approach...

Flex 3: manually sort a DataGrid after applying an automatic sort (clicking on the column header)

Hi! I have a DataGrid in Flex3 which I want to sort by means of clicking on the column header and then tweak this order using a manual sort, dragging and dropping items. I have found out that once you use the column header to sort, there is no way to get rid of this behaviour (unless establishing the data provider's sort property to nu...

Java: How do I sort multiple ArrayList by their size?

I have 9 different ArrayList and I want to have a list of the top 5. I'm thinking of sorting those ArrayLists by their sizes. Is it possible to do that? If so, how can I achieve that? After a few try i finally got it working, just want to share it with everyone. it will be better to get the size of the arraylist and add it to th...

How to sort the following file using shell script ?

I have a text file like below 11:00AM JOHN STAMOS 1983-08-07 I like Pizza Hut 12:00AM JACK SPARROW PIRATE 1886-09-07 I like Pizza Hut and DOminoz 11:00AM SANTA 1986-04-01 I like cold beer How do I sort the above file on the date column? The problem I am facing is due to the variable length name column. Some people have first middle la...