All Questions
4,726 questions
-3
votes
0
answers
25
views
Sort list of keys (Python) [duplicate]
I have a dictionary with the following keys in a list (ListOfKeys = list(MyDict.keys())):
['1002', '1008', '1012', '1016', '1020', '1026', '103', '1030', '1034', '1038', '1044', '1048', '1052', '1056',...
-4
votes
2
answers
74
views
Sort a list of lists when one of the sort items is text month
I am trying to sort this list of lists by the year and then by month,I can get the years part sorted but am stuck when I try to do secondary sort by month. I have created a dict and a list to try to ...
1
vote
0
answers
34
views
How to correctly set orderHint to preserve checklist item order in Microsoft Planner via Power Automate?
Title:
How to correctly set orderHint to preserve checklist item order in Microsoft Planner via Power Automate?
Question:
I'm working on a Power Automate flow that clones a Microsoft Planner bucket, ...
0
votes
0
answers
53
views
How to implement reverse programming with task assignment based on this priority list of items in a Python table?
I need to fix a program with a backward scheduling logic that allows assigning tasks following the priority order in which they appear in the headers of the schedule_table columns.
Since this is a ...
-2
votes
1
answer
81
views
Creating a python function that sorts a list
Created a python function that takes a list and sorts out a list. However I don't get an output when I run the function with a list.
def sort1(w):
my_sort =[]
for num in w :
min_num = ...
0
votes
1
answer
42
views
Android Kotlin order List of Week Day Names by Localization
I have an small problem.
I create an List with the day names of a week that I use for the title row of an month calendar.
But the problem is the first row of the calendar starts on different week days,...
0
votes
1
answer
50
views
Fixing logic toplace consecutive elements in a List Table Column
I need to create a Python program that places highest_priority_order = "Order B" into schedule_table following this logic:
It means that I need to add 2 consecutive hours in the "...
1
vote
1
answer
80
views
Pandas order column with lists by pairs
Here is the dataframe:
df1 = pd.DataFrame( {'st': {0: 1, 1: 0, 2: 2, 3: 0, 4: 1, 5: 5, 6: 0, 7: 7, 8: 19, 9: 0, 10: 0, 11: 0, 12: 3, 13: 0}, 'gen': {0: 'B1', 1: 'A0,B0', 2: 'A1,B1', 3: 'A0,B0', 4: '...
0
votes
2
answers
91
views
How to jump to next element once match has been found in a for loop?
Python beginner here. In a list such as:
lst = [1,1,1,1,1,2,2,2,3,3,3,3,4,4,4]
One pair would be (1,1) , (2,2) , (3,3), etc. When this happens it should count as ONE pair.
(1,2) , (2,3), or (3,4) is ...
0
votes
1
answer
46
views
Controlling the ordering of the output of dplyr::group_split
I have split up a dataframe into a list of sub-dataframes (sub_dfs) using dplyr::group_split. These sub_dfs``` contain data which I then create a separate plot for each. However, I want to create ...
-1
votes
1
answer
56
views
Removing specific value from list, Python
I have a list with dictionaries. Each of them contains an object. What is the proper way to remove one specific dictionary, with its object's lowest attribute value?
balls = [{'body': Body(), 'color': ...
2
votes
3
answers
167
views
python place the longest word in list last
list1 : ['beg', 'begs', 'big', 'bug', 'buggies', 'bugs', 'bus', 'egg', 'eggs', 'gig', 'sub', 'sue', 'use'] BUGGIES
I have a list of words but want to put the longest word 'buggies' at the end of the ...
0
votes
1
answer
65
views
How to sort a list of lists of lists by the total number of items?
I have a list:
[
[['4', '10'], ['2', '6'], ['1', '3']],
[['1', '4', '10'], ['5', '2', '6'], ['11', '1', '3']]
]
I want to sort by the total number of items. The first group has the item 4, 10, 2, ...
0
votes
1
answer
44
views
Sorting a ctypes list without grabbing the value
I'm trying to create a reference to a value in a list and then modify that value in a loop. However, I can't seem to figure out how to sort the data without grabbing its contents.value with list ...
0
votes
2
answers
49
views
what is the most efficient way to gather all points at a certain height?
I have a List[List[int]] that represents points [x,y]
points = [[1,2],[1,3],[2,1],[2,3]]
What is the most efficient way to gather-up all the points with a specific height ?
So if we want all points ...
0
votes
0
answers
76
views
When running list.Sort(), 'NullReferenceException' error occurs
public class SortTest
{
public class Student
{
public int age;
public int grade;
public Student(int age, int grade)
{
this.age = age;
...
2
votes
4
answers
65
views
Can't get this sort function to work in Python
I have been writing a function to sort and pick out specific words to form a sentence. The problem is I cannot for the life of me get any form of .sort or sorted to work. I need the items on the list ...
-2
votes
2
answers
54
views
Unique elements in a Python list using "set" [duplicate]
"""
arr = map(int, input().split())
arr1=list(arr)
print(f"My list:" + str(arr1))
print(f"After sorting in reverse order:" + str(arr1))
arr1.sort(reverse=True)
...
1
vote
1
answer
38
views
sorting a list of tuples using lambda, python [duplicate]
I have a list of tuples that contains (name, score).
I want to sort the list on the second element (reverse = True) and if two names are similar then sort it on first element but not using reverse.
I ...
-2
votes
1
answer
59
views
Alphabetize a List of Names in Python from a list of inputs without being able to use any sort of sort function [closed]
I do not have a lot of programing experience, but I've been trying to get a program working were from a number of inputs it can alphabetize a list and print it going up and down without showing any of ...
-1
votes
1
answer
63
views
Change the positions of values in List 1 based on the values present in List 2 [closed]
List 1: [CBZCYRUQ, CBDYBZQ, CBZDAEQM, CBZDAEUP, CBZDAEUO, CBZDAEUN, CBDYBZR, CBDYBZS, CBZDAEUL, CBZDAEUK]
List 2: [CBDYBZS, CBDYBZR, CBZDAEUL]
The expected output is: [CBZCYRUQ, CBDYBZQ, CBZDAEQM, ...
0
votes
2
answers
95
views
Sort List in Alphanumeric Order
I'm trying to sort a list after zip.
list_sort = zip(l1, l2)
l1 = ['F2', 'G2', 'A10', 'H2', 'A3', 'E3', 'B10', 'C1', 'D1', 'E1', 'D2', 'C11', 'A1']
l2 = [40, 40, 90, 90, 90, 90, 90, 120, 120, 120, 120,...
-2
votes
2
answers
49
views
Custom sort list in Python [duplicate]
There are a number of files in a folder like this:
'920.jpg'
'920-1.jpg'
'920-2.jpg'
When I want to get a list of files, the order of the files is as follows:
[
'920-1.jpg',
'920-2.jpg',
'...
-1
votes
1
answer
79
views
Why does my Python sort function return None instead of the sorted list? [duplicate]
I am working on a Python project where I need to sort a list of integers. I wrote a custom function to sort the list, but instead of returning the sorted list, it returns None. Here is the function I ...
1
vote
2
answers
88
views
How to write sort by key function in ballerina?
string[] arr = ['abcd-4', 'abcd-1', 'abcd-3', 'abcd-2']
Here is my list. I need this array to be get sorted by the key as the last number after '-'. I know there is a sort function in ballerina but ...
0
votes
1
answer
238
views
How should I sort the elements of the Hackerrank practice challenge nested list and then output the second lowest score the right way?
I tried sorting this challenge in so many ways but this time apparently my script is sorting the wrong way this time.
The challenge consists in you inputing the students name and score then the script ...
0
votes
0
answers
53
views
Jinja - sort a list by another list
I have this jinja code:
select
{% for field in (["a", "b", "c"])|sort() %}
{% if field.startswith('mac_') %}
macro_init[{{field}}],
{% else %}
{{...
0
votes
1
answer
23
views
Batch cmd List folders and sort them descending order
I want to list just the folders in a given path (not files and not subfolders) and create a text file from the listed names without any other info besides the names of the folders and to sort them ...
0
votes
0
answers
38
views
How to see if two lists of nonhashable objects are the same in any order in python?
I have two lists of nonhashable objects of the class, let's say, Car with many attributes for each object. An operator overloader for == is defined for the class such that car1==car2 if all the ...
0
votes
1
answer
73
views
Creating an efficent and time-saving algorithm to find difference between greater than and lesser than combination
I want to create a python script, where I have a list of 14 digits and have to find the integer formed by a specific combination of all digits, with the requirement that the number of such ...
0
votes
1
answer
87
views
How can I sort different elements based on keywords?
I'm trying to sort different sentences from a text file according to the part of speech of the specified word in each sentence. For example: Given the big [house] and the {red} flower, I want to ...
0
votes
0
answers
10
views
List Division in Period Folding [duplicate]
I have two lists of x and y values, respectively (~200k coordinate pairs total) representative of a sinusoidal wave. It's period ends at the 300th coordinate point; I've been tasked with dividing the ...
1
vote
1
answer
164
views
sort array of floating point numbers in tcl
I just learned about tcl. I'm sorting an array of integers but I get the error. I still don't know how to solve this problem.
puts [lsort [list 22.678 11.456 7.6 3.521 8.9 4.987 9.245 10.7765]]
The ...
-1
votes
1
answer
98
views
Comparison in python without functools.cmp_to_key(func)
I would like to sort a list after doing some complex comparison with the values in it. For instance,
sorted_result = sorted(unsorted_list, key=functools.cmp_to_key(complex_compare), reverse=True)
...
0
votes
0
answers
30
views
How do I pass a compare function to the sort method instead of the key-function in python? [duplicate]
I know already that i can pass my own sorting criteria to the sort function by defining a function, which assigns keys to the objects that i want to sort. For example if i would like to sort a list of ...
-1
votes
1
answer
112
views
valid mountain array leetcode problem to be solve in python language need help to review code
enter image description here
class Solution(object):
def validMountainArray(self, arr):
"""
:type arr: List[int]
:rtype: bool
"""
...
0
votes
1
answer
90
views
Efficiently sorting through a generator of paths in order to find the longest one
I am trying to write a function that calculates the maximum number of unexplored cells in a grid that is reachable within a given fuel limit. For example I have a 10x10 grid, and each cell in the grid ...
-1
votes
1
answer
68
views
How do I add a number into a sorted list?
So, I have an assignment from my school to add a number into a sorted list, but not just a list- IntNode list, which is if I get it right a linked list (maybe I'm wrong I dont know what this thing is ...
0
votes
2
answers
76
views
Java - Storing Sorted List Values in Memory
Quick Explanation:
I have a Hashmap that stores lists in different orders depending on their sortType. I want this to be stored in memory so that I don't have to sort each list on runtime, many times ...
1
vote
1
answer
173
views
Efficient list sorting: Using heap instead of standard sorting is slower
I'm trying to create a more efficient way to sort lists and dictionaries in python and came across Efficient data structure keeping objects sorted on multiple keys. There the suggested solution was to ...
1
vote
2
answers
120
views
NullPointerException when using Comparator with nullsLast
I know there are many similar questions about the same issue. However, I've tried the solutions provided and none worked for me. I am 100% sure it is something basic I am missing, but I am not able to ...
1
vote
1
answer
39
views
How do I sort specific elements in list in javascript?
In javascript, I want to sort specific elements which are represented by variables in list in automatic way.
const PHQ = [
{
q: '1',
a: [
{ answer: '1', type: ['a']},
{ answer: '...
2
votes
1
answer
41
views
fixing the way how to sort element in a list using python sorted method [duplicate]
I have this list containing the following images with these the name structure "number.image"
The list stores the elements of a local folder based on a path.
[1.image, 2.image, 3.image, 4....
1
vote
1
answer
83
views
Order list elements according to a vector
Say I have a list like:
my_list <- list(name1 = 'a', name2 = 'b', name3 = 'c', name4 = 'd')
And I want to order it according to the following variable:
my_var=c('name2','name1','name4','name3')
I ...
0
votes
0
answers
30
views
sorting a list of objects by two properties
So I have a list of objects which have a point 2d as a property on them. Up until now I've been using this function to sort the list by the X values going left to right
BalloonList.Sort(Function(...
-3
votes
1
answer
156
views
Sorting the List by Stream API in two orders
I have an array of class Person. Let's call it arr_Person. Each instance of the Person class has an int priority type parameter that can take the values 0,1,2,3,4.
I need to get a sorted list of ...
1
vote
2
answers
93
views
Custom List Sort by Part of String
Apologies if this question has already been answered, but none of my searches returned what I'm looking for.
What I need is a method to sort a list of strings, but the sorting needs to be done by a ...
-2
votes
4
answers
176
views
How to do a correct insensitive sorting of a string list in Python?
It seems that I cannot sort insensitively a string list correctly. I will give a simple example. I have tried the following methods with lst = ['b', 'B', 'a', 'A'].
lst.sort(key=str.lower)
lst.sort(...
1
vote
2
answers
64
views
Algorithm to obtain indices of list where list element resets to near zero
I have list of increasing and decreasing float values:
As you can see in the image, the values may increase or decrease and may suddenly reset to
near zero value. I want to know exactly where these ...
2
votes
2
answers
68
views
I want to sort a file containing 150 lines of badge numbers , last names, first names, addresses, etc. alphabetically based on the last name.e
I have a file list containing 150 lines, each line contains 14 comma separated strings : badge number ,last name, first name ,etc. When I add a new name to the list I want to re- arrange the lines ...