Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7757181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:01:06+00:00 2026-06-01T13:01:06+00:00

i have created an application which show data from user current location. I want

  • 0

i have created an application which show data from user current location.
I want to sort them in assending order on the base of minimum distance found of the user.
I know that i need to use this kind of function:

[userLocationd istanceFromLocation:cameraLocation];

But, what do i do after that? I should sort everyone after distance and putting them in an array, but how do i rearrange every cell then according to minimum location get of the user? (cellForRowAtIndexPath)

Also; i havent really figured out how to find the users location. I am on that, but it would be helpful if someone pointed me in the right direction.

How to sort the array to min distance to maximum location?

i have used this code.

    CLLocation *location1 = [[[CLLocation alloc] initWithLatitude:someLatitude longitude:someLongitude] autorelease];

    CLLocation *location2 = [[CLLocation alloc] initWithLatitude:coordinate.latitude longitude:coordinate.longitude];

    float target = [location2 distanceFromLocation:location1];
    target = target / 1000;

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:01:08+00:00Added an answer on June 1, 2026 at 1:01 pm

    i have found the solution use this code it will work perfect

     uint smallest[5];
    
        NSMutableArray *array = [[NSMutableArray alloc] initWithObjects:[NSNumber numberWithDouble:0.5], [NSNumber numberWithDouble:0.25], [NSNumber numberWithDouble:1], [NSNumber numberWithDouble:0.75], [NSNumber numberWithDouble:0.15], [NSNumber numberWithDouble:0.85], [NSNumber numberWithDouble:0.95], [NSNumber numberWithDouble:0.32], [NSNumber numberWithDouble:0.21], [NSNumber numberWithDouble:0.05], nil];
    
        // declare flags
        uint flags[array.count];
    
        // initialize flags
        for(uint i = 0; i < [array count]; i++)
            flags[i] = 0;
    
        for(int i = 0; i < 5; i++)
        {
            smallest[i] = -1;
            for(int j = 0; j < [array count]; j++)
            {
                // check flag
                if(!flags[j])
                {
                    if(smallest[i] == -1 ||
                       [[array objectAtIndex:smallest[i]] doubleValue] > [[array objectAtIndex:j] doubleValue])
                    {
                        // reset flag for previous index
                        if(smallest[i] != -1)
                            flags[smallest[i]] = 0;
                        // set flag for current index
                        flags[j] = 1;
                        smallest[i] = j;
                    }
                }
            }
        }
    
        for(uint i = 0; i < 5; i++)
            NSLog(@"Smallest[%u]: %u -> %f", i, smallest[i], [[array objectAtIndex:smallest[i]] doubleValue]);
    

    if anybody have any problem than please link to this question dedicated to original developer MatthewD

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an application which inserts data into a SQL database. Basically, from
I am developing an android application in which i have to show data from
We have created an application which we want to run in a 64 bit
I want to globalize my application. I have created a small form which asks
I have created an application which needs 'hand-over' to the support group in the
I have created an application which needs to have a profile box tab which
I have created a small application which opens,reads and creates Excel files. The app
I have created a simple win 32 application..in which it has a textbox and
I have created a blog application using Ruby on Rails which includes the ability
I have created a Web Application in asp.net 2.0. which is working fine on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.