HI,

I want to sort the elements of an array in ascending order. The elements are in floating point. how do i go about doing this?

Thanks for your help.

Nishant

Recommended Answers

All 7 Replies

Have you done any research on qsort?

i know that such a function exists... but i don't know the syntax for using it....

Should i just say qsort followed by the array name?

>but i don't know the syntax for using it....
That's what references are for. I can guarantee that you won't get a warm reception if you waste peoples' time with RTFM or STFW questions.

Yes.. i saw that... May be before you're rude to people you should give some thought to the fact that programmers aren't the best when it comes to communicating and MAYBE the language they use is a bit obtuse for a greenhorn to understand.
It's quite easy being condescending when you've spent all your life learning things and the person you're talking to has only just begun... I wonder if you were talked to in this fashion when you first started out learning.

In any case, thanks for your help. I hope it did your ego good to realise that, after years of studying and learning, you know more than a guy who's been programming for a grand total of 1 month.

Cheers,
Nishant

>It's quite easy being condescending when you've spent all your life
>learning things and the person you're talking to has only just begun...
It's also quite easy to forget that I've worked very hard to get where I am, and while I'm very generous in offering help, leeching off of my generosity is extremely insulting. If you want me to respect your lack of experience, I want you to respect the effort I've put into gaining experience and the time I spend sharing it with others. Keep in mind that I volunteer to help people such as yourself in my free time.

>I wonder if you were talked to in this fashion when you first started out learning.
Nope, and would you like to know why? Because I had nobody to help me when I first started learning. I had to figure things out for myself with minimal resources and tools. That's why I'm rude to people who want me to "open head/insert knowledge" for them without any effort on their part.

I clearly remember my early struggles, and I can see them mirrored in beginners these days. But there's a frustrating difference in attitude. The abundance of free help turns your brains to mush and instills an attitude of dependence on other people to do your thinking. I hate that, it stunts your growth and it's depressing, especially since you might be my next co-worker.

All warring aside. . .

Please be more specific when you post the thread. Your first post barely gives any info on what your problem is and where you are stuck up.

>but i don't know the syntax for using it..
If your problem is only finding out the syntax, you're wasting your time here. Maybe you had already seen the reference and you didn't understand a particular concept. Again, being more specific leads to quicker answers.
For ex, if you had trouble understanding the concept of pointers which is used in the reference, here's a good article: pointers . Or if you didn't understand how function prototypes, declarations and definitions work, here's another:Functions.

Yes.. i saw that... May be before you're rude to people you should give some thought to the fact that programmers aren't the best when it comes to communicating and MAYBE the language they use is a bit obtuse for a greenhorn to understand.
It's quite easy being condescending when you've spent all your life learning things and the person you're talking to has only just begun... I wonder if you were talked to in this fashion when you first started out learning.

In any case, thanks for your help. I hope it did your ego good to realise that, after years of studying and learning, you know more than a guy who's been programming for a grand total of 1 month.

Cheers,
Nishant

Please stop such talkings... Narue is far more experienced that you or me... No one has ordered him "Hey Narue, sit here and help this guy out"... he is volunteering... now that counts a lot... i mean it...
Moreover, have you tried to code it?... if so where is the code?... put in some effort... ohhh yeah I forgot, you are a newbie right?... well is there any rule telling "newbies need not put any efffort, come to DANIWEB and they will do the homework for you, huh?"... come on guys be realistic...

Anyways... Sorting an array in ascending order isn't much of an issue... you can use the qsort or else put in a simple logic like...

1. Take the first element
2. Compare it with the rest of the elements
3. If you find any element less than the one you have, swap it
4. Take the next element from the array
5. continue from 2 until the array is exhausted


For qsort, check this out, there is an example also...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.