jsup/avle code update - you don't have to write post everyday

by joviansummer original STEEMIT post: https://steemit.com/blog/@joviansummer/jsup-avle-code-update-you-don-t-have-to-write-post-everyday Hello, this is @joviansummer, developer of @jsup and@avle voting service. Voting service code for @jsup and @avle has been updated. I had been considering this update for a while, and recently I could come up with detailed implementation plan which resulted in a relatively swift code revision. The new added feature is capability to give daily upvote to the first thing you write for the day(timezone GMT+9) regardless of post or comment/reply. Writing a post everyday can be challenging. In that case, you can write a reply to receive daily upvote because writing a reply everyday is much easier and also a good way to engage in your community. Writing a post everyday just to get an upvote can be very tedious and exhausting, and post itself could easily become low-quality. There may be people who enjoy writing a post everyday, but we can't ignore th...

파이썬에서 리스트(list) 정렬(sort)

by joviansummer
original STEEMIT post: https://steemit.com/blog/@joviansummer/list-sort


sorted() 함수를 이용해서 리스트에 담긴 값들을 정렬할 수 있습니다.

x = [1, 3, 5, -1, 0]

# x의 값을 오름차순으로 정렬하여 x_sorted에 할당
x_sorted = sorted(x)

결과값을 비교하면 아래와 같습니다.

print(x) [1, 3, 5, -1, 0]

print(x_sorted) [-1, 0, 1, 3, 5]

반대로 내림차순 정렬을 하려면 아래와 같이 합니다.

# x의 값을 내림차순으로 정렬하여 x_sorted_rev에 할당
x_sorted_rev = sorted(x, reverse=True)

print(x_sorted_rev)

[5, 3, 1, 0, -1]

리스트에 문자열을 저장했을 경우에도 정렬이 됩니다.

y = ['xyz', 'def', 'abc']
y_sorted = sorted(y)

print(y_sorted) ['abc', 'def', 'xyz']

한가지 생각할 점은, 리스트에 담긴 값들이 같은 종류의 값이어야 한다는 점입니다. 예를 들어 문자열(string)과 정수(int)가 혼합된 리스트에서는 sorted() 함수를 사용하지 못합니다.

Comments

Popular posts from this blog

Nuitka - 파이썬 스크립트를 바이너리 실행 파일로 변환

[ENG] jsup 2.0 - make your upvote great again

[EN] STEEM-services: dapps/services webpage with sort and search functions