sorting,char,comparison,lisp,common-lisp , Char Comparison in Common Lisp


Char Comparison in Common Lisp

Question:

Tag: sorting,char,comparison,lisp,common-lisp

How can i compare characters with Common Lisp? I have google it and found out that there are some functions to do the comparison, like char=, char/=, char<, char>, char<=, and char>=. But, i can't use all of the functions just like:

(char= 'a 'a)  
(char< 'a 'b)

If i type those command, CLISP just give me the error message "Argument A is not a character". Why "A" is not a character? I have to write like (char= #\a #\a) to make it working. I want to make functions to did character sorting.

Thank you. Sorry for my bad english.


Answer:

A is a symbol, not a character. The string functions will accept symbols and use the symbol's name, but the character functions only accept true character objects, which are entered using #\ syntax. So you can do:

(string< 'a 'a)
(string< 'a 'b)

For reference:


Related:


Associative array not storing first result from SQL


php,mysql,arrays,sorting
I have a database in MySQL and I'm using this query to select certain rows from it using PHP: $q = "SELECT Number, Body FROM boxes WHERE Number BETWEEN '1' AND '4' ORDER BY Number ASC"; Then calling the query and initiating arrays: $r = $mysqli->query($q); $row = mysqli_fetch_array($r, MYSQLI_ASSOC);...

Conversion from char to int and printing the decimal value


c,char,printf,decimal,ascii
char str[20]; printf("Enter anything\n"); scanf("%s",str); for(int i = 0 ; i<strlen(str) ; i++) { if( isdigit(str[i])) printf("%d",(int)str[i]); } I tried with the above code but the output is in ASCII values of the numbers rather then actual numbers. Like , input: "0" output: "48". When I try (int)(str[i]-'0'); instead of...

Ranking with time weighting


python,algorithm,sorting,math
I am looking for a basic algorithm that gives more weigh to the recent reviews. So, the output value of the algorithm is mutable. For example, two reviews with exactly the same score, will have a different ranking based on the timestamp of the creation. Review_1 Score 10 creation 10/5/2014...

Sort arrayList based on both date and ID


java,sorting
i want to sort the list of task,first by date and then by taskID below is the code ArrayList<fullist> taskdet = new ArrayList<fullist>(); public static class fullist { public int date; public int id; public fullist(int id, int date) { this.date = date; this.id = id; } } i used...

Sum NA values in r


r,sorting,na
I am using a dataframe that has multiple NA values so I was thinking about sorting the attributes based on their NA values. I was trying to use a for loop and this is what I have so far: > data <- read.csv("C:/Users/Nikita/Desktop/first1k.csv") > for (i in 1:length(data) ) {...

SSRS re-sorts data meticulously sorted from the SQL query! Why?


sql-server,sql-server-2008,sorting,reporting-services
I'm writing up a report using SQL Server Reporting Service via Visual Studio 2008. I have a stored procedure on a SQL Server database that returns a list in which I need the entry with value "F" in colulmn [Column] to be always on top, as such: F A B...

Formatting a Pivot Table in Python


python,sorting,pandas,format,dataframes
I am trying to reformat a table based on counts in different columns. df = pd.DataFrame({'Number': [1, 2, 3, 4, 5], 'X' : ['X1', 'X2', 'X3', 'X3', 'X3'], 'Y' : ['Y2','Y1','Y1','Y1', 'Y2'], 'Z' : ['Z3','Z1','Z1','Z2','Z1']}) Number X Y Z 0 1 X1 Y2 Z3 1 2 X2 Y1 Z1 2...

Sort array by keys in custom order


php,arrays,sorting
I have the following multidimensional array Array ( [June 2015] => Array ( [LOW] => Array ( [0] => 160.50 ) [MEDIUM] => Array ( [0] => 0.00 ) [HIGH] => Array ( [0] => 60.80 ) ) [July 2015] => Array ( [MEDIUM] => Array ( [0] => 226.00...

Sorting a dictionary value which is a list of objects by given fields


c#,linq,sorting,dictionary
I have a SortedDictionary whose value is a List of objects. I want to sort the value(the list) of each key by a given property of the object. In the current situation, I need to sort the list first by objects's lastname, then by firstname. I tried LINQ and it...

Sort when values are None or empty strings python


python,list,sorting,null
I have a list with dictionaries in which I sort them on different values. I'm doing it with these lines of code: def orderBy(self, col, dir, objlist): if dir == 'asc': sorted_objects = sorted(objlist, key=lambda k: k[col]) else: sorted_objects = sorted(objlist, key=lambda k: k[col], reverse=True) return sorted_objects Now the problem...

scanf get multiple values at once


c,char,segmentation-fault,user-input,scanf
I need to get in one single shot different inputs from one single line. In particular I need to get a single char and then, depending on which char value I just read, it can be a string and an int or a string, an int and another string and...

Merge multiple lists based on List priority


java,sorting,collections,priority
I have couple of lists where each list has different priority. When i merge these lists i should get with height priority on top. Assume i have 3 lists and different objects value common in 3 lists should come first and then the top priority list should be appended vice...

java 8 stream groupingBy sum of composite variable


java,sorting,java-8,grouping,java-stream
I have a class Something which contains a instance variable Anything. class Anything { private final int id; private final int noThings; public Anything(int id, int noThings) { this.id = id; this.noThings = noThings; } } class Something { private final int parentId; private final List<Anything> anythings; private int getParentId()...

Sort function giving floating point exception for a large input of 0's


c++,sorting,radix-sort,floating-point-exceptions
I have written a code for this problem: Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330. Note: The result may be very large, so you need to return...

Sorting jQuery dataTables by class name when there is no type or value


javascript,jquery,sorting,jquery-datatables
I'm using DataTables: https://www.datatables.net/ Heres my HTML: <div class="dataTable_wrapper"> <table class="table table-striped table-bordered table-hover center" id="dataTables-example"> <thead> <tr> <th>ID</th> <th>Title</th> <th>Actions</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>title 1</td> <td><a href="./action-1"><span class="on"></span></a></td> </tr> <tr>...

Sorting based on the rules set by a string variable


c++,qt,sorting,c++11
In my hypothetical app, I receive a list of hotels from the server. struct Hotel { std::string name; // e.g. Hilton, Ritz int stars; // In range [0..5], 0 stands for "unrated" int freeRoomCount; // Number of available rooms [0..N] int parkingPlacesAvailable; // Number of parking places availalble [0..M] }...

Sort array of objects by subarray property value in javascript


javascript,arrays,sorting,sub-array
I have an array of JavaScript objects: var people = [ { "name": "Edward", "age": 100, "wallet": { "location": "home", "cash": 500 }, "bank": { "location": "bank street", "cash": 22100 } }, { "name": "Lisa", "age": 30, "wallet": { "location": "home", "cash": 20 }, "bank": { "location": "bank street", "cash":...

WPF MVVM custom Sorting issue


c#,asp.net,wpf,sorting,mvvm
I am trying to create custom sorting WPF Data Grid. I have did database call on every sorting. I have used MVVM for this. Issue is I am always getting Sort Direction of column always null on sorting event when I make DB Call. If I remove UpdateData method from...

Sort my str_repeat


php,sorting,repeat,alphabetical
I have spent the past 6 hours trying to figure out how to sort my str_repeat alphabetically based on game. So far all I have been able to do is get it to show the first one in the list as if it was alphabetized. Here is my code. $result...

Should checking loop conditions be counted towards total number of comparisons?


c++,algorithm,sorting,c++11
I have implemented three different sorting algorithms and now I want to confirm that my approach of counting the total number of comparisons is correct. In my mind, the number of comparisons shouldn't be tied to the conditional branches because if the condition isn't met, the comparison was still made...

Sorting vector of Pointers of Custom Class


c++,sorting,c++11,vector
I have vector<FPGA*> current_generation_, which I'd like to sort by FPGA member fitness_ using the sort_members function. Applicable code follows: bool sort_members (FPGA* fpga_first, FPGA* fpga_second) { return (fpga_first->fitness() < fpga_second->fitness()); }; fpga.hpp #include <vector> class FPGA { public: explicit FPGA(int input_gates, int output_gates, int normal_gates); const int fitness(); protected:...

Javascript sort array of objects in reverse chronological order


javascript,arrays,sorting
I have an array of objects which holds a list of jobs and I would like to sort them in reverse chronological order as they would appear on a resume for example. I came up with the below solution which 'seems' to work but I was wondering if there is...

Sorting issue: i have li and i want it to sort by clicking on Asc and Desc


jquery,html,sorting
I want to sort list Ascending and Descending order. When i click on Ascending it will sort on Ascending order same as Descending order,Sorting should be apply by using jQuery or any other javascript library. Example code added on jsfiddle please click on link jsfiddle <p><a href="#" id="asc">Ascending</a> | <a...

C++ error: deduced conflicting types for parameter 'T' string vs const char *


c++,string,templates,c++11,char
So, I am writing a simple, templated search function for deque container. Here's the code: template <typename T> void searchInDequeFor(std::deque<T> Deque, T searchValue) { for(const auto & element : Deque) { if(Deque.empty()) { std::cout << "Deque is empty, nothing to search for..." << "\n"; } else if(element==searchValue) { std::cout <<...

Program to reverse a string in C without declaring a char[]


c,string,pointers,char
I need to reverse a given string and display it without using the value At[index] notation , I tried the below program using pointers,but it does not print anything for the reverse string, Please help! int main() { char* name=malloc(256); printf("\nEnter string\n"); scanf("%s",name); printf("\nYou entered%s",name); int i,count; count=0; //find the...

Given an array/object of datetimes, how can I return an array/object of the times sorted by hour and times sorted by days of the week


php,arrays,sorting,datetime,laravel
PHP/Laravel, I'm getting an array of objects that includes date times for each record. I need to generate analytics on objects on an hourly basis of a day and daily basis of a week. So for example: For a date range of 1/1/2015 - 1/10/2015 I return 100 records all...

converted string failed to contain correct values of float


c,pointers,char
I am facing problem in converting float to char*. I have written a function that will put integer part of float in string and then decimal values. I need it for two places of decimal. But something is horribly wrong. Either it ouputs integer value or just 1 place after...

How do you build the example CUDA Thrust device sort?


c++,visual-studio-2010,sorting,cuda,thrust
I am trying to build and run the Thrust example code in Visual Studio 2010 with the latest version (7.0) of CUDA and the THURST install that comes with it. I cannot get the example code to build and run. By eliminating parts of the code, I found the problem...

Does MongoDB find() query return documents sorted by creation time?


database,mongodb,sorting
I need documents sorted by creation time (from oldest to newest). Since ObjectID saves timestamp by default, we can use it to get documents sorted by creation time with CollectionName.find().sort({_id: 1}). Also, I noticed that regular CollectionName.find() query always returns the documents in same order as CollectionName.find().sort({_id: 1}). My question...

elastic search sort in aggs by column


sorting,elasticsearch,group-by,order
I am trying to sort in elastic search in aggs, equivalent in mysql "ORDER BY Title ASC/DESC". Here is the index structure: 'body' => array( 'mappings' => array( 'test_type' => array( '_source' => array( 'enabled' => true ), 'properties' => array( 'ProductId' => array( 'type' => 'integer', 'index' => 'not_analyzed'...

EXC_BAD_ACCESS error occurring when running recursive merge sort method in a thread


c++,multithreading,sorting,recursion
I'm having trouble with my C++ code in xCode. I've tried debugging and I can't fix it. I know it's roughly when my mergeSort() method calls my mergeNumbers() method. I know it's not the method itself because I've run the method without threading and it works just fine. It's when...

Javascript Sorting Array of Objects [duplicate]


javascript,arrays,sorting,object
This question already has an answer here: Sorting an array of JavaScript objects 14 answers (Please excuse any errors - this is my first post and I am also relatively new to Javascript) I'm trying to sort an array of objects by a specific property value in Javascript. I...

Efficiently sorting large arrays of people by their proximity to the user


javascript,arrays,sorting,mobile,latitude-longitude
So I'm trying to create a list of the 15 closest people in an array of varying sizes. The array will almost always be ~100 objects in size, but for the sake of testing, I'm trying to make it work with 10,000 (there may be need for the project to...

Sort four (4) javascript arrays with 10 objects each by a value


javascript,sorting
model w/ sample data => [{ date: '13413413', name: 'asdfasdf', other: 'kjh' }] getJSON returns 4 arrays of 10 model objects each. array1 = 10 of resultsObj sorted by date from newest to oldest array2 = 10 of resultsObj sorted by date from newest to oldest array3 = 10 of...

Freeing array of dynamic strings / lines in C


c,string,sorting,malloc,free
I am writing a program that is sorting the lines from the input text file. It does its job, however I get memory leaks using valgrind. #include <stdio.h> #include <stdlib.h> #include <string.h> char* getline(FILE * infile) { int size = 1024; char * line = (char*)malloc(size); int temp; int i=0;...

Sort List of Numbers according to Custom Number Sequence


list,python-2.7,sorting
Question :A set of numbers will be passed as input. Also the redefined relationship of the digits 0-9 in ascending order will be passed as input. Based on the redefined relationship, the set of numbers must be listed in ascending order. Input Format: The first line will contain the the...

sorting vector of pointers by two parameters


c++,sorting,vector
I am trying to sort a vector of pointers to a class A using std::sort, but am having some difficulties. Imagine class A beings just a point, containing x and y coordinates. I want to sort the vector by y coordinates from biggest to lowest using some fixed offset value....

Sorting a HTML structure


javascript,html,sorting
Im trying to sort a div structure based on a paramter using a small javscript i found. It seems to not perform exactly as expected. I understand the sorting function is not parsing the values perfectly... This is the sorting logic is use... <script type="text/javascript"> // Sorting Logic $(function() {...

getchar() not working in c


c,while-loop,char,scanf,getchar
getchar() is not working in the below program, can anyone help me to solve this out. I tried scanf() function in place of getchar() then also it is not working. I am not able to figure out the root cause of the issue, can anyone please help me. #include<stdio.h> int...

Comparison method violates its general contract when sorting


java,sorting,comparison
I keep getting: Comparison method violates its general contract! Exception for the below compare function when I call Arrays.sort(ScreenItems) One assumption I have is that the ParseInt below is throwing an exception for the left object but not to the right object Could that be the case? public int compare(Object...

Finding a number that is sum of two other numbers in a sorted array


arrays,sorting,find,sum
As it said in the topic, I have to check if there is a number that is the sum of two other numbers in a sorted array. In first part of the question (for a unsorted array) I wrote a solution, just doing 3 loops and checking all the combinations....

WPF Listbox Collection custom sort


wpf,sorting,listbox,compare,collectionview
I have a listbox DropPrice MyPrice Price1 Price2 I want to sort it like this Price1 Price2 DropPrice MyPrice I mean, if there's an item that starts with the sequence "price", it gets priority, else the smallest string should get the priority. My source code: var lcv = (ListCollectionView)(CollectionViewSource.GetDefaultView(_itemsSource)); var...

How do I remove duplicate objects in an array by field in Javascript?


javascript,arrays,sorting,object
I have an array of objects: [{ id: 1, name: 'kitten' }, { id: 2, name: 'kitten' },{ id: 3, name: 'cat }] How do I remove the second kitten? Sorting into an array of names doesn't work, because I can't know if I am deleting id 1 or or...

char* string substract function throws exception


c++,arrays,string,char
I'm working on my own string class called PString, I have this function that finds a specific character, like 6, and now I have this function called substr short fo substract, where I want to substract from 0 to [insertnumber]. the way I'm trying to call this is by doing...

C# sorting arrays in ascending and descending order


c#,arrays,sorting
I'm having trouble writing a method that returns true if the elements of an array (numbers) are in sorted order, ascending or descending, and false, if they are not in any sorted order. I can return a correct boolean value if the array is ascending but i do not know...

Find column with unique values move to the first column and sort worksheets


excel,vba,excel-vba,sorting
I have 2 worksheets with the same headers in different orders. Headers are I.D, Name, Department, Sales, Start date, End Date and a few others. What I am aiming to do is search through the workbooks in which the headers may be in different orders, find the column which has...

Algoritm to sort object by attribute value without allowing gaps or duplicates


python,sql,django,sorting,django-orm
I have a agenda with multiple dates, each date can contain 0 > ... items. Items can be sorted by position, positions should be Integer values without gaps and duplicates. class Item(models.Model): date = models.DateField() position = models.IntegerField() def move_to(position): qs = self.__class__.objects.filter(date=self.date) # if the position is taken, move...

Sort multiple columns of Excel in VBA given the top-left and lowest-right cell


excel,vba,excel-vba,sorting
I am trying to sort these three columns (Sort By Col-2) in excel using VBA. Top-left (Row number and Column number e.g. 1,1) and lowest-right cell (Row number and Column number e.g. 9,3) are known. Every cell contains the values of String type. Input: Col-1 Col-2 Col-3 P1 I1 XYZ...

Sort Array by Date and Size (Files)


java,arrays,sorting
I've got a method that returns to me a String[] of names of the Files of a current path, the thing I'm trying to do is make a method that returns to me this String[] of names but sorted by date, and sorted by size, I've almost done this, but...

Sorting in Ruby on rails


ruby-on-rails,json,sorting
I'm very new to Ruby on rails. I try to edit the following api. I want to sorting "can_go" which is true are shown at the top of list. I added this row before sending data, but the result is still order by "user_id". user_infos.sort { |a, b| - (a['can_go']<=>b['can_go'])...