sorting
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: sorting

  1. #1
    Join Date
    Jan 2006
    Posts
    64

    Smile sorting

    .In a text file there are numbers upto 10 Million randamly...Those numbers should be sorted.How would u do?

    Regards
    vinni

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,605

    Re: sorting

    • read numbers from the file into an array
    • sort numbers
    • write numbers back to the file
    Victor Nijegorodov

  3. #3
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,621

    Re: sorting

    If there are too many numbers to fit in computer memory:

    * Divide into portions that do fit
    * Sort each portion separately
    * Save sorted results to individual files
    * Merge the results by reading these sorted files, always picking the smallest number available in any file.

    This is called a merge sort
    Nobody cares how it works as long as it works

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center