C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD # Arranging Ten Inputted Numbers into Ascending and Descending order ## Arranging Ten Inputted Numbers into Ascending and Descending order Tag : chash , By : user109285 Date : November 27 2020, 09:01 AM

Does that help I want to create a program that lets me enter ten different numbers in ten different textboxes, then later on sort these inputted numbers into ascending OR descending order. The windows form application design has ten textboxes in it, a button named "Sort" (the button that will sort out the numbers depending on the radio button of your choice) and two radio buttons named "Ascending" and "Descending". The design also have ten labels, wherein the sorted out numbers will be displayed after the user clicked on the Sort button. However, I'm finding troubles regarding the actual coding itself, I considered using a nested for loop but couldn't handle the conditions. Now I've used an array supported with multiple if else statements. , Try this
``````using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
List<TextBox> textBoxes = null;
List<Label> labels = null;
public Form1()
{
InitializeComponent();

textBoxes = new List<TextBox>() { textBox1, textBox2, textBox3, textBox4, textBox5, textBox6, textBox7, textBox8, textBox9, textBox10 };
labels = new List<Label>() { label1, label2, label3, label4, label5, label6, label7, label8, label9, label10 };

for (int i = 0; i < textBoxes.Count; i++)
{
labels[i].Text = textBoxes[i].Text;
}
for (int i = 0; i < labels.Count - 1; i++)
{
int iInt = int.Parse(labels[i].Text);
for (int j = i + 1; j < labels.Count; j++)
{
int jInt = int.Parse(labels[j].Text);
if (jInt < iInt)
{
iInt = int.Parse(labels[j].Text);
string temp = labels[i].Text;
labels[i].Text = labels[j].Text;
labels[j].Text = temp;
}
}
}
}
}
}
​
``````
``````using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
List<TextBox> textBoxes = null;
List<int> numbers = new List<int>();
List<Label> labels = null;
public Form1()
{
InitializeComponent();

textBoxes = new List<TextBox>() { textBox1, textBox2, textBox3, textBox4, textBox5, textBox6, textBox7, textBox8, textBox9, textBox10 };
labels = new List<Label>() { label1, label2, label3, label4, label5, label6, label7, label8, label9, label10 };

for (int i = 0; i < textBoxes.Count; i++)
{
}
numbers = numbers.OrderBy(x => x).ToList();
for (int i = 0; i < numbers.Count; i++)
{
labels[i].Text = numbers.ToString();
}
}
}
}
​
`````` Boards Message : You Must Login Or Sign Up to Add Your Comments .

## arranging numbers in ascending order

Tag : c , By : kuba53280
Date : March 29 2020, 07:55 AM
it fixes the issue This is quite basic program called selection sort.
The wiki article is: Selection sort.
``````a = number [i];
``````
``````number [i] = number [j];
``````
``````number [j] = a;
``````
``````a = number [i];
number[i] = number [j];
number [j] = a;
``````

## arranging strings in ascending and descending order

Tag : java , By : ranja
Date : March 29 2020, 07:55 AM
wish of those help I would take a different approach entirely. Yours is very homegrown, and Java has stuff built in that can do this, most notably here, the Stream API and Comparators
``````String quitString = "quit";
List<String> userInputList = new ArrayList<>();

try(Scanner scanner = new Scanner(System.in)){ // This is called a "try with resources"
System.out.println("Start the sequence by inputting a string DIFFERENT than 'quit'. When you DO want to end it, input \"" + quitString + "\"." + System.lineSeparator());

String encore = scanner.nextLine();

while(!encore.equalsIgnoreCase(quitString)){
encore = encore.replaceAll("\\s+", ""); // this way, the length of the strings is only defined by the characters in the string, and not characters + whitespaces.
System.out.println("Enter the string you want to put in your sequence of strings");

encore = scanner.nextLine();
if(encore != null && !encore.isEmpty() && !encore.equalsIgnoreCase(quitString)) {
}
}
}
catch(Exception e)
{
e.printStackTrace();
}

List<String> ascending =
userInputList.stream()
.sorted((strA, strB) -> strA.length() - strB.length())
.collect(Collectors.toList());

List<String> descending =
userInputList.stream()
.sorted((strA, strB) -> strB.length() - strA.length())
.collect(Collectors.toList());

StringBuilder sbAscending = new StringBuilder();
sbAscending.append("Here are your strings in ascending order: ");
ascending.forEach(userInput -> {
sbAscending.append(System.lineSeparator() + userInput);
});

System.out.println(sbAscending.toString());

StringBuilder sbDescending = new StringBuilder();
sbDescending.append("Here are your strings in descending order: ");
descending.forEach(userInput -> {
sbDescending.append(System.lineSeparator() + userInput);
});

System.out.println(sbDescending.toString());
``````
``````Start the sequence by inputting a string DIFFERENT than 'quit'. When you DO want to end it, input "quit".

Start
Enter the string you want to put in your sequence of strings
test
Enter the string you want to put in your sequence of strings
test2
Enter the string you want to put in your sequence of strings
test23
Enter the string you want to put in your sequence of strings
test234
Enter the string you want to put in your sequence of strings
quit
Here are your strings in ascending order:
test
test2
test23
test234
Here are your strings in descending order:
test234
test23
test2
test
``````

## Arranging strings in ascending and descending order using array lists

Tag : java , By : Hunter
Date : March 29 2020, 07:55 AM
hop of those help? I would suggest you to sort the list using Collections.sort(); and Collections.reverse(); Also, you don't need the else if (descending == null) since you already initialized descending. Your code will look something like,
``````import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
public class Test2 {
public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);
System.out.println("Start the sequence by inputting a string DIFFERENT than 'quit'. When you DO want to end it, input 'quit'");
String longest = "";

List<String> ascending = new ArrayList<String>();
List<String> descending = new ArrayList<String>();
int loop = 0;
Comparator<String> comparator = new Comparator<String>() {
public int compare(String o1, String o2) {
return o1.length() - o2.length();
}
}

String encore = "";
while(true){
loop++;
System.out.println("Enter the string you want to put in your sequence of strings");
encore = scanner.nextLine();
if (encore.equalsIgnoreCase("quit")) {
break;
}

encore = encore.replaceAll("\\s+", ""); // this way, the length of the strings is only defined by the characters in the string, and not characters + whitespaces

Collections.sort(ascending, comparator);
Collections.sort(descending, comparator);
Collections.reverse(descending);
}

for (String str: ascending) {
if (str.length() > longest.length()) {
longest = str;
}
}

if (ascending.size() > 0) {
System.out.println("Here are your strings in ascending order : " + ascending);
System.out.println("Here are your strings in descending order : " + descending);
System.out.println("Here is the longest string : " + longest);
} else {
System.out.println("You have not entered any strings, therefore the program doesn't display any string :("); // customised message.
}

scanner.close();
}
}
``````
``````import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Test2 {
public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);
System.out.println("Start the sequence by inputting a string DIFFERENT than 'quit'. When you DO want to end it, input 'quit'");
String longest = "";

List < String > list = new ArrayList < > ();
int loop = 0;

String encore = "";
while(true){
loop++;
System.out.println("Enter the string you want to put in your sequence of strings");
encore = scanner.nextLine();
encore = encore.replaceAll("\\s+", ""); // this way, the length of the strings is only defined by the characters in the string, and not characters + whitespaces

if (encore.equalsIgnoreCase("quit")) {
break;
}
}

for (String str: list) {
if (str.length() > longest.length()) {
longest = str;
}
}

if (list.size() > 0) {
Collections.sort(list, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return o1.length() - o2.length();
}
});
System.out.println("Here are your strings in ascending order : " + list);
Collections.reverse(list);
System.out.println("Here are your strings in descending order : " + list);
System.out.println("Here is the longest string : " + longest);
} else {
System.out.println("You have not entered any strings, therefore the program doesn't display any string :("); // customised message.
}

scanner.close();
}
}
``````

## Arranging numbers within the digits in descending order without using arrays

Tag : java , By : Zinovate
Date : March 29 2020, 07:55 AM
I hope this helps . Assuming that your number is not greater than Integer.MAX_VALUE you can use Redix Sort algorithm. It works fine with the complexity of O(n). Here, you can find the solution in following code, that doesn't use any array or lists and Strings.
``````public static void main(String[] args) {
int number = 45322;
int sortedNumber = 0;

/*
* This loop checks for each digit starting from 9 to 0.
* In case of ascending order it should be 0 to 9.
*/
for (int i = 9; i >= 0; i--) {
int tmpNumber = number;
while (tmpNumber > 0) {
int digit = tmpNumber % 10;
// Check for the greatest digit in the given number
if (digit == i) {
sortedNumber *= 10;
sortedNumber += digit;
}
tmpNumber /= 10;
}
}
System.out.println(sortedNumber); // prints 54322.
}
``````

## Laravel- arranging records in ascending and descending order

Tag : php , By : msugar
Date : March 29 2020, 07:55 AM
this will help There are many ways you can achieve the sorting issue but as you have setup your page let me tell you the way you can sort records. Create another action which point to your settings.photos route
``````public function settings_photos(\$property_id) {

\$form = Input::get('submit');
\$orderBy = \$form == "Ascending" ? "asc" : "desc";

# Fetch Images in of Specific Property
\$list_of_images = Image::where('property_id', \$property_id)
# Order by Asc/Desc
->sortBy('id', \$orderBy)->get();

return view('settings.photos', ['image_array' => \$list_of_images]); }
``````
``https://stackoverflow.com/questions/50432659/laravel-arranging-records-in-ascending-and-descending-order#``
``````<form name="asc" action="{{route("settings.photos")}}" method="post" class="text-center">

@csrf

<input type="image_id" value="{{\$id}}" />
<input type="submit" value="Ascending " class="settings-photos-header2 text-center"/>  |
</form>

<form name="dec" action="{{route("settings.photos")}}" method="post"  class="text-center">
@csrf
<input type="image_id" value="{{\$id}}" />
</form>``````
``````public function create()
{
\$image = PropertyUser::where('user_id', '=', Auth::user()->id)->get();
foreach(\$image as \$property)
{
\$id = \$property->property_id;
}
\$image_main = Image::where('property_id', \$id)->get();
return view('settings.photos', ['image_array' => \$image_main, 'id' => \$id]);
}
``````
{"ft_lang_label":"__label__en","ft_lang_prob":0.62728846,"math_prob":0.73471016,"size":8684,"snap":"2021-04-2021-17","text_gpt3_token_len":2042,"char_repetition_ratio":0.15046082,"word_repetition_ratio":0.37279597,"special_character_ratio":0.2824735,"punctuation_ratio":0.21273886,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95865834,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12],"im_url_duplicate_count":[null,null,null,null,null,null,null,1,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-01-21T21:02:40Z\",\"WARC-Record-ID\":\"<urn:uuid:45f04da5-b749-4da4-b8f3-5caed2d8dec7>\",\"Content-Length\":\"50708\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:5822e48f-c4b6-4aa8-a768-7c4109b9fd11>\",\"WARC-Concurrent-To\":\"<urn:uuid:9dbe559d-3b9d-441a-8809-0abb074affdd>\",\"WARC-IP-Address\":\"173.212.224.190\",\"WARC-Target-URI\":\"https://scrbit.com/6013887/arranging-ten-inputted-numbers-into-ascending-and-descending-order\",\"WARC-Payload-Digest\":\"sha1:WS3TEWS7BFCLWHG6ADE2Z4UL3LTSCOFK\",\"WARC-Block-Digest\":\"sha1:UAPBCSDFUMYU2Y5J4E3GT2FAKWCOJR5S\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-04/CC-MAIN-2021-04_segments_1610703527850.55_warc_CC-MAIN-20210121194330-20210121224330-00691.warc.gz\"}"}