Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm going to sort 18-digit numbers like 100930200153461004, 100930200153461004 etc. It's nearly about 20K numbers to be sorted out. Which methods or ways can I use to make this happen fast. I'm using C#.net.
Thanks.
18 digit numbers should fit in a Int64. Just put them all in a List and call List.Sort().
20K numbers to sort isn't a lot really. Using the standard Sort() will already try to optimize the sorting algorithm depending on your input, no need to write your own.
There are lot of sorting methods. I would say sorting is not related to any language like C# or php, but before you implements it in any of your computer language. Have a good study of how the different sorting algorithms works. See the link - http://www.sorting-algorithms.com/
thanks
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 days ago.
Improve this question
I'am making a game with unity where I will use Oxford 5000 english words and the translations in my native language and create a game focused on teaching english words to non native speakers.
I'am planning on using 2 Dictionaries each containing 5k words every word will have an ID which match the ID of their translation, Is this a correct approach? Is it ok to have 5k data in a single Dictionary?
2 Huge Dictionaries is it okay?
It depends what you mean by "okay".
If you're asking if that will crash the program, no, it won't. It will work.
But at the very least, I'd recommend keeping both words in a custom struct/class so you're not duplicating the keys in two dictionaries needlessly.
As with most programming, though, the best answer is to try it out. And if it doesn't work, fix it.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
I know stackoverflow has many questions like this one, but it appears that none of them are actually a solution to this.
I had a coding interview three weeks ago and one of the questions been "How do you sort an array of n people by their name in an alphabetical order ?" problem is not the answer, but Array.Sort() function was not allowed.
First thing that came in my mind was creating an array of chars of which i i can attempt to get the first char of each string from that array and store them in char[], then a nested loop to actually do the job, but after a few minutes passed this has no sense and it was or i think a wrong approach by me.
Looking in the Internet the algo that i am looking for is the Quicksort method, but this totally looks something overcomplicated, do i actually need to learn about Quicksort and replicate the algo myself or there is something less complicated that orders that array of people alphabetically ?
Exchange Sort and Bubble Sort are two quite simple sorting algorithms that can be written on the fly.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have similar requirements to those mentioned in this question: compare two phone numbers
I want to compare phone numbers which are in different formats. For example, +467856753421 = 07856753421 = 7856753421.
Is it possible to do it without using the google library recommended in the linked question?
You could try to write a method that sanitises the input string to a standard format, and compare them, but phone numbers have so many different formats that something is bound to slip through the gaps, this is an area where I would strongly recommend a well-tested library that someone else has spent all that time writing for you.
Try this regex:
(^[+]\d{2}|^0*|^00\d\d)(\d*)
The first capture group is your prefix. The second is your number.
(This might need some adjustment if you have US prefixes which are +1 and 001.)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I'm creating a mini code generator in c#. Say i have a string
string val= "i=0;i<5;i++";
As I'm taking complete structure of for loop as a string. How to find the syntax error if user gives wrong input? For example terminator missing or other logical errors? Should i have to use regex?
No i don't think regex is good option because you have to take many things into consideration.
but i would suggest try this instead
https://support.microsoft.com/en-us/help/304655/how-to-programmatically-compile-code-using-c-compiler
using c# compiler itself to do work for you.
but keep that in mind this will ask for whole c# code so you may have to do some string manipulation to get around that.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I would like to ask for any sample queries that used to retrieve multiple field from table to do maths calculation?
Another thing is, should I do the calculation in the rdlc report by using Expression, or using queries?
I don't understand your first question. But I will gladly answer your second one from my point of view:
I try to do most calculations on the Database. Because thats what a database should do and complex expressions are not very good and easy to maintain.
You will have to use Expressions on top of that alle the time (in complex reports) so I prefer to do all on the Database that can be done there.
But only as long as your SQL Queries are maintainable and fast.