473,657 Members | 2,654 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Selection sort algorithm using strcmp

14 New Member
I need hints for an algorithm using string compare in a selection sort.
I will be sorting lastnames and first namesalphbetica lly. if the selection sort encounters the same last name it then goes to first name and alphabetizes the list.

Smith, John
Smith, Juan



THANKS IN ADVANCE!!
Apr 23 '07 #1
1 4161
RedSon
5,000 Recognized Expert Expert
I need hints for an algorithm using string compare in a selection sort.
I will be sorting lastnames and first namesalphbetica lly. if the selection sort encounters the same last name it then goes to first name and alphabetizes the list.

Smith, John
Smith, Juan



THANKS IN ADVANCE!!
What are you talking about? What kind of hints are you looking for. Its pretty straight forward, use string compare to do a selection sort. Do you know what the algorithm for selection sort looks like? Do you know how to use string compare functions?
Apr 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
13098
by: JasBascom | last post by:
say i had 97456 and 23456 is there already a sort function to check which one begins with the smaller number rearrange it. in this case the bottom number should clearly be rearranged to the top as it lower in numerical order.
2
2111
by: JasBascom | last post by:
I thought it was too much to put this program in with my last message. The program compiles ok, but when I execute, I get access errors. can someone put it through their compiler please. I think the problem lies when i declare union Allrecords h1,h2,h3. and then use them to toupper record_type. the debug when i use it can not go past the switch statement. thank you for you help
8
2566
by: Les Coover | last post by:
I have tried writing the selection process after scanf many different ways. No matter what is selected program execution goes to the add_data function. How can I get this to work? /* em_at01.c */ #include <stdio.h> void add_data(void);
48
4455
by: Alex Chudnovsky | last post by:
I have come across with what appears to be a significant performance bug in ..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same data. Same data on the same CPU gets sorted a lot faster with both methods using .NET 1.1, that's why I am pretty sure its a (rather serious) bug. Below you can find C# test case that should allow you to reproduce this error, to run it you will need to put 2 data files into current directory...
4
5336
by: Hunk | last post by:
Hi I have a binary file which contains records sorted by Identifiers which are strings. The Identifiers are stored in ascending order. I would have to write a routine to give the record given the Identifier. The logical way would be to read the record once and put it in an STL container such as vector and then use lower_bound to search for a given identifier. But for some strange reason i'm asked to not use a container but instead...
0
8514
Ganon11
by: Ganon11 | last post by:
Earlier, mmccarthy was kind enough to post a short article explaining the Bubble Sort. As she said, this is a relatively slow sorting algorithm. Here, I will attempt to present a slightly faster algorithm called Selection Sort. Imagine you have a list of numbers in random order. You want to sort these numbers in increasing order - that is, every element is smaller than or equal to the next element. It follows that the first element holds...
1
8469
by: mosullivan | last post by:
I had to write a program that would accept 7 strings through scanf, list the strings, alphabetize, and relist. I was supposed to use strcmp to assist with the sort and write it so that it can sort on a different number by only changing the N_STRINGS 7. So, I've written the program and of course it's not working I admit that the pointers to strings and arrays confuse me. Can someone point me in the right direction? I would appreciate any...
7
7139
by: mahdiahmadirad | last post by:
Hi dears! I wrote a simple bubble sort algorithm. it works properly when we compare full arrays but i want to sort a 2d array according to a specific part of array. it has some problem to swapping this array. please help me. my scenario: assume that we have a big 2d char array for example students for 20 persons an 30 character for each person. first 15 chars contains first name and the rest is last name. no i want to sort this array...
0
8394
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6164
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4152
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.