using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication17
{
class Class1
{
public void Test()
{
var data = new string[] { "1",
"1.2", "0.98",
"0.93", "1.38",
"0.99" };
Array.Sort(data, VersionComparer);
display(data);
}
static int
VersionComparer(string s1, string s2)
{
List<int>
parts1 = s1.Split('.').Select(int.Parse).ToList();
List<int>
parts2 = s2.Split('.').Select(int.Parse).ToList();
while (parts1.Count < parts2.Count)
parts1.Add(0);
while (parts2.Count < parts1.Count)
parts2.Add(0);
for (int i = 0; i
< parts1.Count; i++)
{
if (parts1[i] < parts2[i])
return -1;
if (parts1[i] > parts2[i])
return +1;
}
return 0;
}
static void display(string[] d)
{
int i;
Console.WriteLine("\nSorted
Arrays Values ");
for (i = 0; i < d.Length; i++)
{
Console.Write(" "+d[i]);
}
}
}
}
|
|
Computer Science :: 11th/12th, Computer Engineering :: Degree/Diploma, Coding Concept ( C, C++ & JAVA Programming, JDBC Concept, DBMS - SQL Concept, Data Structure, Communication & Network Concept.
Tuesday, November 24, 2015
C# SORTING DECIMAL VALUES BASED ON LIST
Subscribe to:
Post Comments (Atom)
JAC Board Computer || IIT 2025 || Introductory Information Technology || Class 10 || Practical Examination 2025
Marks Division HOE 30 Marks IT Application Report File 20 Marks Viva - Voce 10 Marks 1) Write an HTML code to generate a web p...
-
1) TCP/IP - Transmission Control Protocol/ Internet Protocol. 2) HTTPs - Hyper Text Transfer Protocol. 3) ICT - Information Comunication Te...
-
1) What is Make Code Arcade? Answer: Make Code Arcade is a coding platform that enables to create block – based program. 2) How ...
-
Programmingway@Eklavya Technosys!: New Year's 2025 | Happiness & Healthier's Life Sty... : भारत कई धर्मों का संगम है, हिंदू, मुस...
No comments:
Post a Comment