Comments (3)
This is not supported yet.
#26 is tracking adding the sort method to lists
#8 is tracking adding keyword arguments
Here is a workaround:
def cmp(a, b): return len(a) - len(b)
a=["ccc", "a","aa"]
a = sorted(a, cmp)
print(a)
To see it in action, you can paste it here: https://rawgit.com/differentmatt/filbert/master/test/interactive.html
Thanks for the feedback!
from filbert.
I just wanted to make a comment regarding your workaround...
cmp is for comparisons of two items. in this case, a and b.
if cmp returns a negative, that means a is less than b.
if it returns zero, they are equal, and if it returns a positive value, greater than
so differentmatt, your code is wrong. here's what it should be:
def cmp(a, b): return len(a) - len(b)
a=["ccc", "a","aa"]
a = sorted(a, cmp)
print(a)
from filbert.
Good catch, updated comment.
from filbert.
Related Issues (20)
- int() rounds negative numbers in the wrong direction HOT 2
- Looping over characters in string gives indexes, not values HOT 1
- [Python] Reassigning a function parameter treats it as undefined until reassignment HOT 1
- Multiple Assignment doesn't work
- Move test python snippets to own files
- Python interpreter
- Implement chained comparisons for numerical ranges (0 < x < 10)
- String to list transformation HOT 2
- Memory usage spikes while trying to parse_dammit certain code. HOT 1
- str(True) and str(False): Cannot read property 'truthy' of undefined
- list.pop(index) doesn't work HOT 3
- Python lists don't have .push method HOT 1
- Null makes its way into ast body.body HOT 1
- v1 target refinement? HOT 2
- Compatibility with browsers HOT 1
- Is the project reviving? HOT 1
- Is there a way to check the types of nodes? (similar to @babel/types) HOT 3
- Taking back parsed object into python code HOT 1
- npm version is out of date HOT 2
- Support of named arguments?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from filbert.