Efficient way to sort large set of numbers

I have to sort a set of 100000 integers as a part of a programming
Q. The time limit is pretty restrictive, so I have to use the most
time-efficient approach possible.

My current code -

#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
int n,d[100000],i;
for(i=0;i<n;++i) {
scanf("%d",&d[i]);
}
sort(d,d+n);
....
}

Would this approach be more efiicient?

int main() {
int n,d[100000],i;
for(i=0;i<n;++i) {
scanf("%d",&d[i]);
sort(d,d+i+1);
}
....
}

What is the most efficient way to sort a large dataset?

Note - Not homework...

 Efficient way to multiply large matrices I am working with some large (over 1 million x 1 million), sparse matrices. I need to multiply 7 of them together, and I am currently using Pythons scipy.sparse modules with the lil_matrix sparse class (before multiplication, I need to slice them, etc). When doing the multiplications, I can get 6 of them to multiply (it appears in any order), yet the 7th fails with the following error message: class="bbcode_container"> PHP Code: class="bbcode_code">File "/usr/local/packages/scipy/0.7.1/lib/python2.4/site-packages/scipy/spars />e/base.py", line 288, in __mul__ />   &nbs Ubuntu Sort a user input list of numbers using python bubble sort I've just started to learn python and I've decided to try and do a bubble sort. I've used the code below which works ok if the numbers to be sorted are 0 to 9. After that, it doesn't sort them correctly. I think, in my limited knowledge that this is because it is a 'list'. I would like the user to be able to input the numbers but for the program to sort them regardless of the length of the number. Any help would be appreciated. def bubble_sort(items): changes=0 for i in range(len(items)): for j in range(len(items)-1-i):#-i = optimised?? if items[j] > items[j+1]: items[j], items[j+1] = items[j+1], items[j] # Swap changes=changes+1 print(items) print("Number of passes =",i) print("Number of swaps =",changes) print("Welcome to a Bubble Sort Algorithm in Python!") while True: print("Enter as many numbers as you want. You can choose between 0 and 9. Leave a space between each one") numbers=input() items=numbers.split() Web Development shift even numbers in an array to left and odd numbers to right and sort even numbers in ascending order and odd numbers in descending order The question is how do I do this using bubble sort and in blue j using 2 loops and an if check having 3 conditions only? Web Development Most efficient way to find smallest of 3 numbers Java? I have an algorithm written in Java that I would like to make more efficient. A part that I think could be made more efficient is finding the smallest of 3 numbers. Currently I'm using the Math.min method as below: double smallest = Math.min(a, Math.min(b, c)); How efficient is this? Would it be more efficient to replace with if statements like below: double smallest; if(a #include using namespace std; int main() { int n,d[100000],i; for(i=0;i

 - Technology - Languages + Webmasters + Development + Development Tools + Internet + Mobile Programming + Linux + Unix + Apple + Ubuntu + Mobile & Tablets + Databases + Android + Network & Servers + Operating Systems + Coding + Design Software + Web Development + Game Development + Access + Excel + Web Design + Web Hosting + Web Site Reviews + Domain Name + Information Security + Software + Computers + Electronics + Hardware + Windows + PHP + ASP/ASP.Net + C/C++/C# + VB/VB.Net + JAVA + Javascript + Programming