Search Results

Search found 10131 results on 406 pages for 'natural sort'.

Page 26/406 | < Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >

  • How do you sort php and sql arrays?

    - by Jon
    How can I sort this array by city or by id in descending order? if ($num > 0 ) { $i=0; while ($i < $num) { $city = mysql_result($result,$i,"city"); $state = mysql_result($result,$i,"state"); $id = mysql_result($result,$i,"id"); echo "$city"; echo "$state"; ++$i; } } else { echo "No results."; } ?>

    Read the article

  • Sort NSFetchedResultsController results by user location

    - by cgp
    I have an application that contains some Locations in Core Data, and I want to show them to the user in order of proximity to the user's location. I am using an NSFetchedResultsController to serve the locations to the Table View. I thought about creating a virtual accessor method that returns the location's distance from the user, that would be calculated using a "global" CoreLocationManager, but it crashes with reason: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath distanceFromCurrentLocation not found in entity < NSSQLEntity Location id=4' I also give the user the option to sort alphabetically, so I would prefer it if I kept the NSFetchedResultsController, if possible. How should I do it? Thanks!

    Read the article

  • Most efficient way to randomly "sort" (Shuffle) a list of integers in C#

    - by Carl
    I need to randomly 'sort' a list of integers (0-1999) in the most efficient way possible. Any ideas? Currently, I am doing something like this: bool[] bIndexSet = new bool[iItemCount]; for (int iCurIndex = 0; iCurIndex < iItemCount; iCurIndex++) { int iSwapIndex = random.Next(iItemCount); if (!bIndexSet[iSwapIndex] && iSwapIndex != iCurIndex) { int iTemp = values[iSwapIndex]; values[iSwapIndex] = values[iCurIndex]; values[iCurIndex] = values[iSwapIndex]; bIndexSet[iCurIndex] = true; bIndexSet[iSwapIndex] = true; } }

    Read the article

  • Database strucure for versioning and multiple languages

    - by phobia
    Hi, I'm wondering how to best solve the issue of content existing in multiple versions and multiple languages. An image of my current structure can be seen here: http://i46.tinypic.com/72fx3k.png Each content can only have one active version in each language, and that's how I'm curious on how to best solve. Right now I have a column of the contentversions table, which means for each change of active version I have to run a update and set active=false on all version and then a update to set active=true for the piece of content in question. Any thoughts? :)

    Read the article

  • Entity Framework and associations between string keys

    - by fredrik
    Hi, I am new to Entity Framework, and ORM's for that mather. In the project that I'm involed in we have a legacy database, with all its keys as strings, case-insensitive. We are converting to MSSQL and want to use EF as ORM, but have run in to a problem. Here is an example that illustrates our problem: TableA has a primary string key, TableB has a reference to this primary key. In LINQ we write something like: var result = from t in context.TableB select t.TableA; foreach( var r in result ) Console.WriteLine( r.someFieldInTableA ); if TableA contains a primary key that reads "A", and TableB contains two rows that references TableA but with different cases in the referenceing field, "a" and "A". In our project we want both of the rows to endup in the result, but only the one with the matching case will end up there. Using the SQL Profiler, I have noticed that both of the rows are selected. Is there a way to tell Entity Framework that the keys are case insensitive? Edit:We have now tested this with NHibernate and come to the conclution that NHibernate works with case-insensitive keys. So NHibernate might be a better choice for us.I am however still interested in finding out if there is any way to change the behaviour of Entity Framework.

    Read the article

  • How does Amazon's Statistically Improbable Phrases work?

    - by ??iu
    How does something like Statistically Improbable Phrases work? According to amazon: Amazon.com's Statistically Improbable Phrases, or "SIPs", are the most distinctive phrases in the text of books in the Search Inside!™ program. To identify SIPs, our computers scan the text of all books in the Search Inside! program. If they find a phrase that occurs a large number of times in a particular book relative to all Search Inside! books, that phrase is a SIP in that book. SIPs are not necessarily improbable within a particular book, but they are improbable relative to all books in Search Inside!. For example, most SIPs for a book on taxes are tax related. But because we display SIPs in order of their improbability score, the first SIPs will be on tax topics that this book mentions more often than other tax books. For works of fiction, SIPs tend to be distinctive word combinations that often hint at important plot elements. For instance, for Joel's first book, the SIPs are: leaky abstractions, antialiased text, own dog food, bug count, daily builds, bug database, software schedules One interesting complication is that these are phrases of either 2 or 3 words. This makes things a little more interesting because these phrases can overlap with or contain each other.

    Read the article

  • Algorithm for sentence analysis and tokenization

    - by Andrea Nagar
    I need to analyze a document and compile statistics as to how many times each a sequence of words is used (so the analysis is not on single words but of batch of recurring words). I read that compression algorithms do something similar to what I want - creating dictionaries of blocks of text with a piece of information reporting its frequency. It should be something similar to http://www.codeproject.com/KB/recipes/Patterns.aspx Do you have anything written in C#?

    Read the article

  • Relation/Sort not working in rails controller?

    - by Elliot
    I have the following relation in my rails app: genre - has many - authors authors - belong to genre and has many books books - belongs to authors and belongs to users (users can add books to the db) in my controller I have: @books=current_user.books(:include => [:author => :genre], :order => 'created_at DESC') While I am able to use the @books variable in my views - nothing is done correctly (i.e. its not showing me only books added by that user, and its not descending by created_at)... any ideas? -- Also I'm using clearance for the user auth, so current_user without the @ in the controller seems to work fine Actually, I think the relation is working, only the sort might not be working...

    Read the article

  • JAVA or JAVA SCRIPT OR Idoc SCRIPT alphabetical sort

    - by tito86
    Hi folks, I have a task: All items within categories should be sorted alphabetically except for Examples. Special characters and numbers should be displayed before letters. I'm facing with a problem. Most of standart sort functions and plugins are being used the ASCII table. In this table the following symboles: ~,},{ etc. have the index more than letters,for example: Actual result of sorting is: 1 - #1 A T 2 - A T 3 - {C T I need to get: 1 - #1 A T 2 - {C T 3 - A T Plese give me your piece of advice or sny examples ASAP. Best Regards.

    Read the article

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

    - by user350468
    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 involving creating classes and specifying an anonymous delegate for the whole compare step but perhaps there is a linq oriented way as well. Thanks in advance for any suggestions.

    Read the article

  • how to sort xml data in jQuery

    - by pixeltocode
    how can i sort all officers based on their ranks jQuery $.get('officers.xml', function(grade){ $(grade).find('officer').each(function(){ var $rank = $(this).attr('rank'); }); }); XML (officer.xml) <grade> <officer rank="2"></student> <officer rank="3"></student> <officer rank="1"></student> </grade> thanks.

    Read the article

  • two php arrays - sort one array with the value order of another

    - by Tisch
    Hi there, I have two PHP arrays like so: Array of X records containing the ID of Wordpress posts (in a particular order) Array of Wordpress posts The two arrays look something like this: Array One (Sorted Custom Array of Wordpress Post IDs) Array ( [0] => 54 [1] => 10 [2] => 4 ) Array Two (Wordpress Post Array) Array ( [0] => stdClass Object ( [ID] => 4 [post_author] => 1 ) [1] => stdClass Object ( [ID] => 54 [post_author] => 1 ) [2] => stdClass Object ( [ID] => 10 [post_author] => 1 ) ) I would like to sort the array of wordpress posts with the order of the ID's in the first array. I hope this makes sense, and thanks in advance of any help. Tom edit: The server is running PHP Version 5.2.14

    Read the article

  • sort associative array PHP

    - by jim smith
    Here's my array, how do I sort it by saleref? Array ( [xml] => Array ( [sale] => Array ( [0] => Array ( [saleref] => 12345 [saleline] => 1 [product] => producta [date] => 19/ 3/10 [manifest] => 0 [qty] => 1 [nextday] => [order_status] => ) [1] => Array ( [saleref] => 12344 [saleline] => 1 [product] => productb [date] => 18/ 3/10 [manifest] => 11892 [qty] => 1 [nextday] => [order_status] => )

    Read the article

  • Javascript to sort contents of select element

    - by Jangwenyi
    Hi, is there a quick way to sort the items of a select element? Or I have to resort to writing javascript? Please any ideas. <select size="4" name="lstALL" multiple="multiple" id="lstALL" tabindex="12" style="font-size:XX-Small;height:95%;width:100%;"> <option value="0"> XXX</option> <option value="1203">ABC</option> <option value="1013">MMM</option> </select>

    Read the article

  • Sort List by occurrence of a word by LINQ C#

    - by Thomas
    i have stored data in list like List<SearchResult> list = new List<SearchResult>(); SearchResult sr = new SearchResult(); sr.Description = "sample description"; list.Add(sr); suppose my data is stored in description field like "JCB Excavator - ECU P/N: 728/35700" "Geo Prism 1995 - ABS #16213899" "Geo Prism 1995 - ABS #16213899" "Geo Prism 1995 - ABS #16213899" "Wie man BBA reman erreicht" "this test JCB" "Ersatz Airbags, Gurtstrammer und Auto Körper Teile" now i want to query the list with my search term like geo jcb if you look then the word geo has stored many times in the description field. so i want to sort my list in such way that the word in search term found maximum that data will come first. please help me to do so. thanks

    Read the article

  • How to sort the row contents on table cell by using date

    - by MS Nathan
    Hi i am new to iphone application development.i am developing RSS feed Reader it has number of different RSS feeds. In my application (XML parsing), i want to display the content of the row on cell for particular date and with their corresponding title, description (in my application, i am using three labels for displaying title, date and description) on table view cell after parsing xml data. And i want to sort the all kinds of RSS feeds row contents(title, date, description) depends upon the date in single another UIViewController and for each RSS feed has a separate ViewController. thanks in advance.

    Read the article

  • Database structure for versioning and multiple languages

    - by phobia
    How can I solve the issue of content existing in multiple versions and multiple languages? My current structure: Each content can only have one active version in each language, and that's how I'm curious on how to best solve. Right now I have a column of the contentversions table, which means for each change of active version I have to run a update and set active=false on all version and then a update to set active=true for the piece of content in question.

    Read the article

  • Javascript: sort objects

    - by tom
    function Player() { var score; this.getScore = function() { return score; } this.setScore = function(sc) { score = sc; } } function compare(playerA, playerB) { return playerA.getScore() - playerB.getScore(); } var players = []; players['player1'] = new Player(); players['player2'] = new Player(); Array(players).sort(compare); I have code that is similar to the above. When I step through the code with a debugger, the compare function never gets called and the array isn't sorted. I'm not sure what's wrong with my code?

    Read the article

  • Data clean up: are there libraries of common permutations that we can use? Or is there a better appr

    - by anyaelena
    We are working on clean-up and analysis of a lot of human-entered customer data. We need to decide programmatically whether 2 addresses (for example) are the same, even though the data was entered with slight variations. Right now we run each address through fairly simplistic string replacement (replacing avenue with ave, for example), concatenate the fields and compare the results. We are doing something similar with names. At the very least, it seems like our list of search-replace values should already exist somewhere. Or perhaps you can suggest a totally different and superior way to detect matches?

    Read the article

  • Custom sort logic in OrderBy using LINQ

    - by Bala R
    What would be the right way to sort a list of strings where I want items starting with an underscore '_', to be at the bottom of the list, otherwise everything is alphabetical. Right now I'm doing something like this, autoList.OrderBy(a => a.StartsWith("_") ? "ZZZZZZ"+a : a ) EDIT: I ended up using something like this; optimization suggestions welcome! private class AutoCompleteComparer : IComparer<String> { public int Compare(string x, string y) { if (x.StartsWith("_") && y.StartsWith("_") || (!x.StartsWith("_") && !y.StartsWith("_"))) { return x.CompareTo(y); } else if (x.StartsWith("_")) { return 1; } else if (y.StartsWith("_")) { return -1; } return 0; } }

    Read the article

  • How to sort Ruby Hash based on date?

    - by Eki Eqbal
    I have a hash object with the following structure: {"action1"=> {"2014-08-20"=>0, "2014-07-26"=>1, "2014-07-31"=>1 }, "action2"=> {"2014-08-01"=>2, "2014-08-20"=>2, "2014-07-25"=>2, "2014-08-06"=>1, "2014-08-21"=>1 } "action3"=> {"2014-07-30"=>2, "2014-07-31"=>1, "2014-07-22"=>1, } } I want to sort the hash based on the date and return back a Hash(Not array). The final result should be: {"action1"=> {"2014-07-26"=>1, "2014-07-31"=>1, "2014-08-20"=>0 }, "action2"=> {"2014-07-25"=>2, "2014-08-01"=>2, "2014-08-06"=>2, "2014-08-20"=>1, "2014-08-21"=>1 } "action3"=> {"2014-07-22"=>1, "2014-07-30"=>2, "2014-07-31"=>1 } }

    Read the article

  • How to sort numbers in array from low to high

    - by Louie
    Hello all, I am trying to sort an array of prices from low to high. I have it working but not the way I want it to. Long story short, the sorter is putting numbers in order like this: 100 10900 200 290 instead of sorting like this 100 200 290 10900 here is my code I am doing this with. -(void)filterPriceLowHigh { NSSortDescriptor *sortDescriptor; sortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"ListPrice" ascending:YES] autorelease]; NSArray *sortDescriptors = [NSArray arrayWithObject:sortDescriptor]; NSArray *sortedArray; sortedArray = [app.vehiclesArrayToDisplay sortedArrayUsingDescriptors:sortDescriptors]; [app.vehiclesArrayToDisplay removeAllObjects]; [app.vehiclesArrayToDisplay addObjectsFromArray:sortedArray]; } Could someone tell me what I need to do here? thanks in advance.

    Read the article

  • Given a document select a relevant snippet.

    - by BCS
    When I ask a question here, the tool tips for the question returned by the auto search given the first little bit of the question, but a decent percentage of them don't give any text that is any more useful for understanding the question than the title. Does anyone have an idea about how to make a filter to trim out useless bits of a question? My first idea is to trim any leading sentences that contain only words in some list (for instance, stop words, plus words from the title, plus words from the SO corpus that have very weak correlation with tags, that is that are equally likely to occur in any question regardless of it's tags)

    Read the article

  • JavaScript BubbleSort

    - by Alyn
    Hi, Have a bubblesort routine similar the this. I need to make it more efficient by stopping the loop when the array is sorted or if the array is already sorted. function sortNumbers(listbox) { var x, y, holder; // The Bubble Sort method. for(x = 0; x < ranarray.length; x++) { for(y = 0; y < (ranarray.length-1); y++) { if(ranarray[y] > ranarray[y+1]) { holder = ranarray[y+1]; ranarray[y+1] = ranarray[y]; ranarray[y] = holder; } } }

    Read the article

< Previous Page | 22 23 24 25 26 27 28 29 30 31 32 33  | Next Page >