Photo number sorting algorithm

if there are millions of phone numbers that need to be sorted, does anybody know if there is a most proper algorithm out there?
I have been searching, but can't find a good one.
Thanks.

If you use any reasonable algorithm your millions of phone numbers will be sorted in less time than it takes to read this reply. Perhaps the real question is why are you sorting those numbers over and over and over so that choice of algorithm matters in the slightest. Sort them once and keep them sorted.

Similar Messages

  • Sort algorithm for LARGE amount of data?

    hi,
    i need a sorting scheme for the following situation:
    I have a data file where entries are in chunks of variable length. The size of each
    chunk is defined in the first 5 bytes as a string, so the length can be from
    00001-99999, though it is usually around 1000-3000 bytes long. In reality it is never
    over 10000 bytes, but it is possible for it to be.
    Anyways, I need to sort these files according to the data found in certain
    displacements in these chunks. I will be sorting anywhere from 200,000 to
    100,000,000 at a time. Time is an issue certainly, but if it takes a week to finish that is
    fine, i just need it to work.
    So, my problem is that none of the typical sorts will work for me (bubble, heap) as far
    as i can tell because in those sorts i need to have the data loaded into memory, and
    this much data will overload the system. I have used, in the past, a c method that
    feeds these chunks to the sort function a few at a time, then makes files. Hence, not
    all chunks need to be loaded at once. Does anyone know of any solution to this
    problem? Any sort algorithms or sort classes that can handle this much data? thanks!

    Ever tried the radix sort? it's got linear complexity.
    You can still work a chunk at a time, and simply separate the data into several different "buckets", each one identified by, oh, say, the unicode number for the first character in the chunk.
    You now have several smaller lists to sort, and when you're done, NO MERGING IS NECESSARY. Simply append the lists, because the main sets of lists are already sifted into different "buckets".
    Kinda like this:
    create 256 files, and store in each every record that contains a first character that corresponds to it's ascii value. Then create 256 files for each of the original 256 files, and store in each every recond that contains a second character that correstonds to it's second character.
    etc, etc, etc.
    This is very memery intensive for storage, but in terms of run time complexity, it is linear: You will make an explicit number of passes through the list of data. And, as you go along, the lists get shorter and shorter. So while it appears that you are making 256 ^ (max length of data) passes, you're really only making (max length of data) passes, with some additional overhead of creating extra multiple files.
    For that much data, I would definitely recommend a linear algorithm. Any other sorts would be extremely slow.

  • Which sorting algorithm Oracle use?

    Hi ,
    May i know which sorting algorithm oracle use ?
    Because when i am using order by with an sorted or unsorted data it is taking same time.
    Thanks in advance

    Pradeep Dewani wrote:
    Hi ,
    But i want to know that whether oracle consider sorted and unsorted data in same way or not ?
    Please help if any body know because i cant decrease number of rows but i can sorted them in a temp table .Pradeep,
    a SORT is usually an additional operation that can be quite costly depending on the amount of data to sort and the available memory for sorting. It would show up in the execution plan as SORT operation.
    Note that the optimizer can take various shortcuts to minimize the impact of a sort operation. If you e.g. use a "top-N" query properly, it can take advantage of a "SORT ORDER BY STOPKEY" operation that only keeps the top N rows sorted in memory.
    If you have suitable indexes, the optimizer might also come to the conclusion that a SORT operation can be eliminated by traversing an index in the requested order, so you could have a query that uses an ORDER BY but the execution plan doesn't show any explicit SORT operations.
    So to answer your question: Oracle doesn't consider sorted and unsorted data in the same way. Sorting is an additional operation that needs to be handled somehow.
    If you have a query that takes the same time whether sorted or not the execution time is probably driven by other factors and the SORT operation is negligible in terms of performance.
    But there are other scenarios possible where a SORT operation takes significant time and influences the execution time. SORTs can also lead to overall changes in the execution plan that are not directly related to the SORT operation.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • Before I buy, will I see the date on photos in sorter?

    I'm looking for the right App to make movie / video  files from a photoshow.  I'm interested in iMovie but am concerned that I won't see the date stamp on my photo files like in the iPad photo albums.  I find this very annoying in the Photo app.  You can't sort or anything.  Will I see the date stamp of when the photo was taken if I download a photo to my iPad?  So I can sequence my pictures for a video?
    When I say date stamp, I don't mean a the date and time right on the photo.  I just want to know when the photo was taken and be able to sort a group of photos based on date taken.

    Photos are sorted by date and time, but the date and time is not shown in the app.

  • How to display the steps of a sort algorithm??

    I'm having a lot of trouble trying to display the results of applying a merge sort to a set of 10 integers. The problem is not that I can't see anything on the text area within the applet, the problem is that I am getting a lot of repetitions and duplicates occuring. I have tried inserting the Display() method in various positions in the sort, I have set up a temporary array to compare the elements of the array before and after the particular step of the sort is applied and an if statement to display only if there are changes have happened to the array. Can anyone advise?? Here's the code for the sort, including my current attempt to get the sort diplayed in steps:
    public class MSort extends JFrame
    public MSort(int[] anArray, JApplet anApplet)
    a = anArray;
    applet = anApplet;
    ArrayUtil.Display(a,textArea);
    JumpLine(textArea);
    Sorts the array managed by this merge sorter
    public void sort()
    throws InterruptedException
    mergeSort(0, a.length - 1);
    textArea.append("End of Merge Sort");
    Sorts a range of the array, using the merge sort
    algorithm.
    @param from the first index of the range to sort
    @param to the last index of the range to sort
    public void mergeSort(int from, int to)
    throws InterruptedException
    if (from == to) return;
    int mid = (from + to) / 2;
    mergeSort(from, mid);
    mergeSort(mid + 1, to);
    merge(from, mid, to);
    Merges two adjacent subranges of the array
    @param from the index of the first element of the
    first range
    @param mid the index of the last element of the
    first range
    @param to the index of the last element of the
    second range
    public void merge(int from, int mid, int to)
    throws InterruptedException
    startPosition = from;
    endPosition = to;
    int n = to - from + 1;
    // size of the range to be merged
    // merge both halves into a temporary array b
    int[] b = new int[n];
    int i1 = from;
    // next element to consider in the first range
    int i2 = mid + 1;
    // next element to consider in the second range
    int j = 0;
    // next open position in b
    int[] oldArray = new int[a.length];
    System.arraycopy(a, 0, oldArray, 0, oldArray.length);
    // as long as neither i1 nor i2 past the end, move
    // the smaller element into b
    while (i1 <= mid && i2 <= to)
    if (a[i1] < a[i2])
              b[j] = a[i1];
    for (int m=0; m < a.length-1; m++) {
    if (a[m] != oldArray[m]){
    ArrayUtil.Display(a,textArea);// method I've put in to try and compare the array b4 and after the sort
    JumpLine(textArea);
    i1++;
    else
    b[j] = a[i2];
    for (int m=0; m < a.length-1; m++) {
    if (a[m] != oldArray[m]){
    ArrayUtil.Display(a,textArea);// method I've put in to try and compare the array b4 and after the sort
    JumpLine(textArea);
    i2++;
         pause(2);
    j++;
         for (int k=0; k < a.length-1; k++) {// method I've put in to                  try and compare the array b4 and after the sort
    if (a[k] != oldArray[k]){
    ArrayUtil.Display(a,textArea);
    JumpLine(textArea);
    // note that only one of the two while loops
    // below is executed
    // copy any remaining entries of the first half
    while (i1 <= mid)
    b[j] = a[i1];
    for (int m=0; m < a.length-1; m++) {
    if (a[m] != oldArray[m]){
    ArrayUtil.Display(a,textArea);// method I've put in to try and compare the array b4 and after the sort
    JumpLine(textArea);
    //ArrayUtil.Display(a,textArea);
                        //JumpLine(textArea);
    pause(2);
    i1++;
    j++;
    // copy any remaining entries of the second half
    while (i2 <= to)
    b[j] = a[i2];
    for (int m=0; m < a.length-1; m++) {
    if (a[m] != oldArray[m]){
    ArrayUtil.Display(a,textArea);// method I've put in to try and compare the array b4 and after the sort
    JumpLine(textArea);
         } pause(2);
    i2++;
    j++;
    // copy back from the temporary array
    for (j = 0; j < n; j++)
    a[from + j] = b[j];
    for (int m=0; m < a.length-1; m++) {
    if (a[m] != oldArray[m]){
    ArrayUtil.Display(a,textArea);// method I've put in to try and compare the array b4 and after the sort
    JumpLine(textArea);
    pause(2);
    public void pause(int steps)
    throws InterruptedException
    if (Thread.currentThread().isInterrupted())
    throw new InterruptedException();
    applet.repaint();
    Thread.sleep(steps * DELAY);
    private int[] a;
    private int startPosition = -1;
    private int endPosition = -1;
         private JTextArea textArea = SortApplet1.getTextArea2();
    private JApplet applet;
    private static final int DELAY = 100;
    public static void JumpLine(JTextArea t){
         JTextArea TxtArea = t;
         TxtArea.append("\n\n");
    }

    see sample at http://lwh.free.fr/pages/algo/tri/tri.htm
    marvinrouge

  • How do I get my photos to sort by file name when sync'd to the iPad?

    How do I get my photos to sort by file name when sync'd to the iPad?  The default sorting method changes the order of pictures when sync'd from my pc.

    http://support.apple.com/kb/HT4221

  • I need to view the photo number.

    Anybody can help, I need to know the photo number. How to view the photo number in iPhoto for iOS version.?

    Apple Support Contact
    Apple Support contact - Telephone

  • Is it possible to rename photo in the "camera roll" OR reset the photo number in iphone 4s? (Clearly explained the situation)

    Hi everyone, nice to meet you all. This is my first discussion starting in here and nice to meet you all. I used Android device before and this is my first apple mobile that I owned. I am using iphone 4s. (5.0.1)
    I have search a lot but no answer that how can I rename the photo in the camera roll in iphone or in Windows 7.
    What I want to do is:
    I have IMG_0006, IMG_0007, IMG_0015, IMG_0016, IMG_0017, total 5 files.
    I want to change the name that make their sequence will become IMG_0001, IMG_0002, IMG_0003, IMG_0004, IMG_0005 and I want the following picture will take place in IMG_0006. (This is just what I want but it never happened)
    but seems that I can't rename them and I have tried that if I take 2 pictures after IMG_0017, but I delete them (which is delete IMG_0018 and IMG_0019), then take another new picture again, it will name as IMG_0020 instead of IMG_0018.
    Questions:
    1. Are there any methods to reset the photo number by deleting file under the "PhotoData" that we can see in iPhone Explorer?
    OR
    2. Are there any methods to rename the photo in the "camera roll" folder?
    I have tried to rename the photo directly in iPhone Explorer but it will make the photo cannot be read in iphone.
    3. Is it possible that I can rename them directly and rebuild the camera roll by deleting the Photos.sqlite under the PhotoData folder to solve the unreadable problem in iphone 4?
    Thanks a lot to read all of the words above

    Thanks for your quick reply. I think I have tried but I cannot.
    There are no any options to let you choose "rename" in Windows 7 if you connect the iphone via USB
    I have tried to rename the photo directly in iPhone Explorer but it will make the photo cannot be read in iphone and just got nothing to show on its screen until I rename it into the previos name again then the picture will show properly.
    May be it can but I do not know how to rename them in Windows 7, could you please show me step by step?

  • 'All Photos' is sorted randomly. Cannot be changed.

    Ok, this is very frustrating.
    I have 10.10.3 and Photos 1.0 (209.52.0).
    I've just dragged about 9000 photos in Photos (all taken with my various iPhones over the years, correct metadata, EXIF, etc). Everything imported fine, with the exception that the 'All Photos' album is randomized. I see a 2013 photo at the very bottom with a bunch of 2015 photos. At the very top are some photos I took before I dragged the 9000 extra in there. Basically it's not respecting photo capture date AT ALL, and is maybe sorting by date/time of import instead. 'Keep sorted by date added' is checked (but frustratingly, greyed out).
    If I go to Years mode, everything is correct as it should be. I can also go into individual albums and sort by date or name.
    It's annoying because 'All Photos' follows the same order on my iPhone too, so i'm seeing a bunch of mixed up photos.
    If I drag 9000 photos into Photos, why in the heck would I want that sorted by date added?
    Anybody else seeing this? I reported this as a bug in the public beta, but no fix so far.
    I really want to like Photos, but man…

    Yeah, I do acknowledge that it's 'date added' rather than 'date captured' in the post. I just meant that it still appeared random to me.
    I figured out what the problem was, and the following post is a solution…
    Turns out a bunch of the files (i.e. the ones out of order) had erroneous file creation dates that didn't match up to the actual capture date. Not sure how that happened. Some were saying they were 'created' several years after they actually were.
    So it looks like (at least when importing) Photos just scans the file creation date rather than the EXIF data. Maybe it's faster to do that, but it's kind of sloppy of Apple. They should know that file creation dates can get messed up.
    To fix all this, I used the excellent ExifTool, which can sync creation/modify date to EXIF. If you don't have ExifTool, the easiest method is to get it using Brew, at http://brew.sh
    Once brew is properly installed and updated, simply type into terminal…
    brew install exiftool
    Once you have that installed, in terminal I 'cd' to the folder of images and then run…
    ExifTool "-FileModifyDate<DateTimeOriginal" *
    The * basically just means modify every file in that folder. I know that UNIX doesn't officially acknowledge creation dates, but this command changes BOTH creation and modification dates to be the same, which is fine in my opinion.
    I then reimported all the images and everything in All Photos is sorted as it should be. Phew!

  • Hi how to find runtime for sorting algorithms

    I am new to java.......please help me out by taking a sorting algorithm and find the run time of it ......
    Thanks in Advance

    If by "runtime" you just mean the amount of time it takes to execute across some set of input...then you can use java.lang.System.currentTimeMillis() to get the current time in milliseconds since Jan 1 1970. Do that both before and after you run the code that implements the algorithm, and subtract to get the difference as running time in milliseconds. Or, if this weren't part of a homework assignment, you could just use a profiler.
    If by "runtime" you mean the execution environment, then you want to use java.lang.Runtime.getRuntime(). This has nothing to do with algorithms.
    If you mean that you want to analyze the efficiency of the algorithm (eg it's "big-O" notation), then read a textbook on algorithms. This has nothing to do with Java, apart from that Java is just one computer language out of many in which algorithms can be implemented.

  • [SOLVED] What is this sorting algorithm? (or a new one?)

    Hello everyone!
    Just before starting, i apologize for my grammar mistakes.
    I found a new sorting algorithm but i'm not sure if i really found it. There are too many sorting algorithms and mine is a really simple one; so, i belive that it can be found years ago.
    I searched popular sorting algorithms, but none of the them is the answer.
    Here is algorithm:
    * Search the numbers between brackets
    [24 12 12 55 64 18 32 31]
    * Find smallest one
    [24 12 12 55 64 18 32 31]
    ^S
    * Swap the first item between brackets with smallest one
    [12 12 24 55 64 18 32 31]
    * Find largest one
    [12 12 24 55 64 18 32 31]
    ^L
    * Swap the last item between brackets with largest one
    [12 12 24 55 31 18 32 64]
    * Move brackets by one.
    12[12 24 55 31 18 32]64
    * Continue from step one until the array is sorted
    /* rottsort
    Copyright (c) 2013 Bora M. Alper
    #include <stdio.h>
    void print_array (const int *array, const int length);
    int rottsort_swap (int *x, int *y);
    void rottsort (int *array, const int length);
    int rottsort_largest (const int *array, const int start, const int end);
    int rottsort_smallest (const int *array, const int start, const int end);
    void print_array (const int *array, const int length) {
    int i;
    for (i=0; i < length; ++i)
    printf ("%d ", array[i]);
    putchar ('\n');
    int main (void) {
    int array[] = {24, 12, 12, 55, 64, 18, 32, 31};
    print_array(array, 8);
    rottsort(array, 8);
    print_array(array, 8);
    return 0;
    int rottsort_swap (int *x, int *y) {
    const int temp = *x;
    *x = *y;
    *y = temp;
    void rottsort (int *array, const int length) {
    int i, largest_pos, smallest_pos;
    for (i=0; i < length/2; ++i) {
    largest_pos = rottsort_largest(array, i, length-1-i);
    rottsort_swap(&(array[largest_pos]), &(array[length-1-i]));
    smallest_pos = rottsort_smallest(array, i, length-1-i);
    rottsort_swap(&(array[smallest_pos]), &(array[i]));
    int rottsort_largest (const int *array, const int start, const int end) {
    int i, largest_pos = start;
    for (i=start; i <= end; ++i)
    if (array[i] >= array[largest_pos])
    largest_pos = i;
    return largest_pos;
    int rottsort_smallest (const int *array, const int start, const int end) {
    int i, smallest_pos = start;
    for (i=start; i <= end; ++i)
    if (array[i] <= array[smallest_pos])
    smallest_pos = i;
    return smallest_pos;
    P.S.: If this is a new sorting algorithm, i name it as "rottsort". :)
    Last edited by boraalper4 (2013-08-11 19:08:17)

    Trilby wrote:
    Because you already have two variables for largets and smallest, there is no reason to loop through the whole list twice to get each.  Loop through the list (or list subset) once, and in each loop check if the current item is smaller than smallest_pos or larger than largest_pos.
    This will increase efficiency by a factor of two.
    As written I believe it'd be less efficient than even a simple bubble sort.  With the above revision it may be comparable to a bubble sort.
    Thanks for quick answer and advice. :) I will try to do that. When i'm done, i will post the new code.
    Code is tested on codepad. (I edited the code on my phone so, sorry for formatting)
    /* rottsort
    Copyright (c) 2013 Bora M. Alper
    #include <stdio.h>
    void print_array (const int *array, const int length);
    int rottsort_swap (int *x, int *y);
    void rottsort (int *array, const int length);
    void rottsort_find (int *smallest_pos, int *largest_pos, const int *array, const int start, const int end);
    void print_array (const int *array, const int length) {
    int i;
    for (i=0; i < length; ++i)
    printf ("%d ", array[i]);
    putchar ('\n');
    int main (void) {
    int array[] = {24, 12, 12, 55, 64, 18, 32, 31};
    print_array(array, 8);
    rottsort(array, 8);
    print_array(array, 8);
    return 0;
    int rottsort_swap (int *x, int *y) {
    const int temp = *x;
    *x = *y;
    *y = temp;
    void rottsort (int *array, const int length) {
    int i, largest_pos, smallest_pos;
    for (i=0; i < length/2; ++i) {
    rottsort_find (&smallest_pos, &largest_pos, array, i, length-1-i);
    rottsort_swap(&(array[largest_pos]), &(array[length-1-i]));
    if (smallest_pos == length-1-i)
    smallest_pos = largest_pos;
    rottsort_swap(&(array[smallest_pos]), &(array[i]));
    void rottsort_find (int *smallest_pos, int *largest_pos, const int *array, const int start, const int end) {
    int i;
    *smallest_pos = start;
    *largest_pos = start;
    for (i=start; i <= end; ++i) {
    if (array[i] >= array[*largest_pos])
    *largest_pos = i;
    if (array[i] <= array[*smallest_pos])
    *smallest_pos = i;
    Last edited by boraalper4 (2013-08-11 15:21:48)

  • Radix sort algorithm

    You guys, I need a radix sort algorithm for java. I've worked on it for a while, and I cant get it. I have this so far:
    public void radixSort(int maxDigits)
              Vector temp = new Vector();
              int count = 1;
              while(count<(Math.pow(10,maxDigits)))
                   int c=0;
                   while(c<10)
                        for(int i=0;i<students.size();i++)
                             int per = ((MyStudent)students.elementAt(i)).getPercentage()/count;                         
                             if(per%10==count)
                                  temp.add((MyStudent)students.elementAt(i));
                        c++;
                   count*=10;
              students = temp;
    students is the main vector in the class, and percentage is the thing we are trying to sort. The accessor for percentage is (MyStudent)students.elementAt(i).getPercentage(). It has to be cast to (MyStudent) object.

    Sorry here is a formatted version of my question:
    You guys, I need a radix sort algorithm for java. I've worked on it for a while, and I cant get it. I have this so far:
    public void radixSort(int maxDigits)
              Vector temp = new Vector();
              int count = 1;
              while(count<(Math.pow(10,maxDigits)))
                   int c=0;
                   while(c<10)
                        for(int i=0;i<students.size();i++)
                             int per = ((MyStudent)students.elementAt(i)).getPercentage()/count;                         
                             if(per%10==count)
                                  temp.add((MyStudent)students.elementAt(i));
                        c++;
                   count*=10;
              students = temp;
         }students is the main vector in the class, and percentage is the thing we are trying to sort. The accessor for percentage is (MyStudent)students.elementAt(i).getPercentage(). It has to be cast to (MyStudent) object.

  • Hi sorry but i have an important question?i have an iphone 4 and i want connect his to i tunes in a second pc because the pc i connect before is broke..how can i do?without lost my photo number or music?

    hi sorry but i have an important question?i have an iphone 4 and i want connect his to i tunes in a second pc because the pc i connect before is broke..how can i do?without lost my photo number or music?

    check out this post by Zevoneer.

  • Quick-Sort Algorithm HELP !!!

    hi there, I wrote a method to sort an 2D-Vector. I used the Bubble-Algorithm.
    Here the code:
    Vector == [Micky, Niko, Tete] ; [Lilo, Eli, Micha];
    public static void bubbleSort( Vector v,
    int sortColumn,
    boolean ascending )
    int i = 0,
    j = 0,
    length = v.size();
    Vector tmp1,
    tmp2;
    for (i = 0; i < (length - 1); i++)
    for (j = i+1; j < length; j++)
    tmp1 = (Vector) v.elementAt(i);
    tmp2 = (Vector) v.elementAt(j);
    if (SortUtil.isGreaterThan(tmp1.elementAt(sortColumn), tmp2.elementAt(sortColumn)) > 0)
    // swap
    SortUtil.swap2D(v, i, j);
    public class SortUtil
    public static int isGreaterThan(Object obj1, Object2)
    // String
    if ( (obj1 instanceof String) && (obj2 instanceof String) )
    return ( ((String) obj1).compareTo((String) obj2) );
    public static void swap2D(Vector v, int i)
    Vector tmp = (Vector) v.elementAt(i);
    v.setElementAt((Vector) v.elementAt(i+1), i);
    v.setElementAt(tmp, i+1);
    I want now to write a method to use the quick-sort-algorithm.
    How can I do this.
    thanks a lot.
    micky z.

    Hi
    You can use java.util.Arrays.sort() method to sort an array of data in quick sort algo. May be you will have to use a n array insted of the Vector.
    Use vector.toArray() method to get an array from the vector.
    But if you want to use a dynamically resizing container like the Vector, use a java.util.LinkedList insted of the Vector and use Collections.sort() method
    Good luck.

  • Sorting algorithm ?

    what is the sorting algorithm used in Collection.sort ?
    Its not clear what sorting algorithm is used in Collection.sort
    http://download.oracle.com/javase/1.4.2/docs/api/java/util/Collections.html
    Can anybody throw some light on this ?

    roy wrote:
    It works on binary search algorithm.No.
    Binary search requires that the list already be sorted. You don't use binary search to do the sorting.
    This algorithm has two forms. The first takes a List and an element to search for (the "search key"). This form assumes that the List is sorted in ascending order according to the natural ordering of its elements. The second form takes a Comparator in addition to the List and the search key.The second form also assumes the list is sorted--according to the rules of the comparator.

Maybe you are looking for